2025-12-11 02:06:04 -06:00
|
|
|
using LANCommander.SDK;
|
2025-03-11 21:21:16 -05:00
|
|
|
using LANCommander.Server.Services.Models;
|
2025-11-16 12:31:25 -06:00
|
|
|
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)
|
|
|
|
|
{
|
2025-11-16 12:31:25 -06:00
|
|
|
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 = [
|
2025-11-16 12:31:25 -06:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|