mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
Always use \n, not Environment.NewLine
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using Management.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
public class FileConfiguration
|
||||
public class FileConfiguration(IConfiguration config)
|
||||
{
|
||||
public static string GetBasePath()
|
||||
public string GetBasePath()
|
||||
{
|
||||
string? storageDirectory = Environment.GetEnvironmentVariable("storageDirectory");
|
||||
string? storageDirectory = config["storageDirectory"];
|
||||
var basePath = storageDirectory ?? Path.GetFullPath("../storage");
|
||||
|
||||
if (!Directory.Exists(basePath))
|
||||
|
||||
@@ -15,7 +15,8 @@ public class FileStorageManager
|
||||
MyLogger<FileStorageManager> logger,
|
||||
CourseMarkdownLoader courseMarkdownLoader,
|
||||
MarkdownCourseSaver saveMarkdownCourse,
|
||||
ILogger<FileStorageManager> otherLogger
|
||||
ILogger<FileStorageManager> otherLogger,
|
||||
FileConfiguration fileConfig
|
||||
)
|
||||
{
|
||||
using var activity = DiagnosticsConfig.Source.StartActivity("loading storage directory");
|
||||
@@ -23,7 +24,7 @@ public class FileStorageManager
|
||||
_courseMarkdownLoader = courseMarkdownLoader;
|
||||
_saveMarkdownCourse = saveMarkdownCourse;
|
||||
_otherLogger = otherLogger;
|
||||
_basePath = FileConfiguration.GetBasePath();
|
||||
_basePath = fileConfig.GetBasePath();
|
||||
|
||||
this.logger.Log("Using storage directory: " + _basePath);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ public class CourseMarkdownLoader
|
||||
private readonly MyLogger<CourseMarkdownLoader> logger;
|
||||
private readonly string _basePath;
|
||||
|
||||
public CourseMarkdownLoader(MyLogger<CourseMarkdownLoader> logger)
|
||||
public CourseMarkdownLoader(MyLogger<CourseMarkdownLoader> logger, FileConfiguration fileConfig)
|
||||
{
|
||||
this.logger = logger;
|
||||
_basePath = FileConfiguration.GetBasePath();
|
||||
_basePath = fileConfig.GetBasePath();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<LocalCourse>> LoadSavedMarkdownCourses()
|
||||
@@ -101,7 +101,7 @@ public class CourseMarkdownLoader
|
||||
var assignmentPromises = assignmentFiles
|
||||
.Select(async filePath =>
|
||||
{
|
||||
var rawFile = await File.ReadAllTextAsync(filePath);
|
||||
var rawFile = (await File.ReadAllTextAsync(filePath)).Replace("\r\n", "\n");
|
||||
return LocalAssignment.ParseMarkdown(rawFile);
|
||||
})
|
||||
.ToArray();
|
||||
@@ -122,7 +122,7 @@ public class CourseMarkdownLoader
|
||||
var quizPromises = quizFiles
|
||||
.Select(async path =>
|
||||
{
|
||||
var rawQuiz = await File.ReadAllTextAsync(path);
|
||||
var rawQuiz = (await File.ReadAllTextAsync(path)).Replace("\r\n", "\n");
|
||||
return LocalQuiz.ParseMarkdown(rawQuiz);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ using System.Threading.Tasks.Sources;
|
||||
using LocalModels;
|
||||
namespace Management.Services;
|
||||
|
||||
public class MarkdownCourseSaver(MyLogger<MarkdownCourseSaver> logger)
|
||||
public class MarkdownCourseSaver(MyLogger<MarkdownCourseSaver> logger, FileConfiguration fileConfig)
|
||||
{
|
||||
private readonly MyLogger<MarkdownCourseSaver> _logger = logger;
|
||||
private readonly string _basePath = FileConfiguration.GetBasePath();
|
||||
private readonly string _basePath = fileConfig.GetBasePath();
|
||||
|
||||
public async Task Save(LocalCourse course, LocalCourse? previouslyStoredCourse)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user