adding last saved course to try to reduces excessive file writes

This commit is contained in:
2023-12-05 14:31:01 -07:00
parent 466aa747b6
commit a77c001601
5 changed files with 17 additions and 12 deletions

View File

@@ -23,9 +23,9 @@ public class FileStorageManager
this.logger.Log("Using storage directory: " + _basePath);
}
public async Task SaveCourseAsync(LocalCourse course)
public async Task SaveCourseAsync(LocalCourse course, LocalCourse? previouslyStoredCourse)
{
await _saveMarkdownCourse.Save(course);
await _saveMarkdownCourse.Save(course, previouslyStoredCourse);
}

View File

@@ -12,7 +12,7 @@ public class MarkdownCourseSaver
_basePath = FileConfiguration.GetBasePath();
}
public async Task Save(LocalCourse course)
public async Task Save(LocalCourse course, LocalCourse? previouslyStoredCourse)
{
var courseDirectory = $"{_basePath}/{course.Settings.Name}";
if (!Directory.Exists(courseDirectory))
@@ -103,6 +103,7 @@ public class MarkdownCourseSaver
var filePath = assignmentsDirectory + "/" + assignment.Name + ".md";
await File.WriteAllTextAsync(filePath, assignmentMarkdown);
Console.WriteLine("saving file");
}
removeOldAssignments(assignmentsDirectory, module);
}