LANCommander/LANCommander.Server/Startup/Filesystem.cs

32 lines
1 KiB
C#
Raw Permalink Normal View History

2025-12-11 02:06:04 -06:00
using LANCommander.SDK;
2025-03-11 21:21:16 -05:00
using LANCommander.Server.Services.Models;
using Microsoft.Extensions.Options;
2025-03-11 21:21:16 -05:00
namespace LANCommander.Server.Startup;
public static class Filesystem
{
public static WebApplication PrepareDirectories(this WebApplication app)
{
var settings = app.Services.GetRequiredService<IOptions<Settings.Settings>>();
2025-03-11 21:21:16 -05:00
var logger = app.Services.GetRequiredService<ILogger<Program>>();
logger.LogDebug("Ensuring required directories exist");
IEnumerable<string> directories = [
settings.Value.Server.Update.StoragePath,
settings.Value.Server.Launcher.StoragePath,
settings.Value.Server.Backups.StoragePath,
2025-12-11 02:06:04 -06:00
settings.Value.Server.Scripts.Snippets.StoragePath,
2025-03-11 21:21:16 -05:00
];
foreach (var directory in directories)
{
logger.LogDebug("Ensuring directory {Directory} exists", directory);
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
}
return app;
}
}