+
+
+
@@ -143,16 +168,19 @@
@foreach (DayOfWeek day in (DayOfWeek[])Enum.GetValues(typeof(DayOfWeek)))
{
-
@@ -161,8 +189,8 @@
-
}
diff --git a/Management/Services/Files/FileStorageManager.cs b/Management/Services/Files/FileStorageManager.cs
index 4b450fb..c9b0d8e 100644
--- a/Management/Services/Files/FileStorageManager.cs
+++ b/Management/Services/Files/FileStorageManager.cs
@@ -21,46 +21,16 @@ public class FileStorageManager
_basePath = FileConfiguration.GetBasePath();
this.logger.Log("Using storage directory: " + _basePath);
-
+
}
-
- // public string CourseToYaml(LocalCourse course)
- // {
- // var serializer = new SerializerBuilder().DisableAliases().Build();
-
- // var yaml = serializer.Serialize(course);
-
- // return yaml;
- // }
-
- // public LocalCourse ParseCourse(string rawCourse)
- // {
- // var deserializer = new DeserializerBuilder().IgnoreUnmatchedProperties().Build();
-
- // var course = deserializer.Deserialize
(rawCourse);
- // return course;
- // }
-
public async Task SaveCourseAsync(LocalCourse course)
{
- // var courseString = CourseToYaml(course);
- // await File.WriteAllTextAsync($"{_basePath}/{course.Settings.Name}.yml", courseString);
-
await _saveMarkdownCourse.Save(course);
}
public async Task> LoadSavedCourses()
{
-
- // var fileNames = Directory.GetFiles(_basePath);
-
- // var courses = await Task.WhenAll(
- // fileNames
- // .Where(name => name.EndsWith(".yml"))
- // .Select(async n => ParseCourse(await File.ReadAllTextAsync(n)))
- // );
- // return courses;
return await LoadSavedMarkdownCourses();
}
@@ -69,4 +39,15 @@ public class FileStorageManager
return await _courseMarkdownLoader.LoadSavedMarkdownCourses();
}
+ public async Task> GetEmptyDirectories()
+ {
+ if(!Directory.Exists(_basePath))
+ throw new DirectoryNotFoundException($"Cannot get empty directories, {_basePath} does not exist");
+
+ return Directory
+ .GetDirectories(_basePath, "*")
+ .Where(dir => !Directory.EnumerateFileSystemEntries(dir).Any())
+ .ToArray();
+
+ }
}
\ No newline at end of file
diff --git a/Management/Services/Files/LoadMarkdownCourse.cs b/Management/Services/Files/LoadMarkdownCourse.cs
index f465f29..ab4ccce 100644
--- a/Management/Services/Files/LoadMarkdownCourse.cs
+++ b/Management/Services/Files/LoadMarkdownCourse.cs
@@ -17,7 +17,13 @@ public class CourseMarkdownLoader
var courseDirectories = Directory.GetDirectories(_basePath);
var courses = await Task.WhenAll(
- courseDirectories.Select(async n => await LoadCourseByPath(n))
+ courseDirectories
+ .Where(d =>
+ {
+ var settingsPath = $"{d}/settings.yml";
+ return File.Exists(settingsPath);
+ })
+ .Select(async d => await LoadCourseByPath(d))
);
return courses;
}
@@ -31,10 +37,13 @@ public class CourseMarkdownLoader
throw new LoadCourseFromFileException(errorMessage);
}
+
+
LocalCourseSettings settings = await loadCourseSettings(courseDirectory);
var modules = await loadCourseModules(courseDirectory);
- return new() {
+ return new()
+ {
Settings = settings,
Modules = modules
};