Implemented statistics. Refactored storage abstractions. Added config options for docker and local storage. Added server service and server updating.

This commit is contained in:
2026-03-02 15:51:05 +00:00
parent 52dbd13fb5
commit 2d1b48b0d4
27 changed files with 493 additions and 147 deletions

View File

@@ -1,3 +1,5 @@
using Microsoft.Extensions.Options;
using MoonlightServers.Daemon.Configuration;
using MoonlightServers.Daemon.Models;
using MoonlightServers.Daemon.ServerSystem.Abstractions;
@@ -5,11 +7,16 @@ namespace MoonlightServers.Daemon.ServerSystem.Implementations.Local;
public class LocalInstallStorageService : IInstallStorageService
{
private const string HostPathTemplate = "./mldaemon/install/{0}";
private readonly IOptions<LocalStorageOptions> Options;
public LocalInstallStorageService(IOptions<LocalStorageOptions> options)
{
Options = options;
}
public Task<IInstallStorage?> FindAsync(string id)
{
var path = string.Format(HostPathTemplate, id);
var path = Path.Combine(Options.Value.InstallPath, id);
if (!Directory.Exists(path))
return Task.FromResult<IInstallStorage?>(null);
@@ -19,7 +26,7 @@ public class LocalInstallStorageService : IInstallStorageService
public Task<IInstallStorage> CreateAsync(string id, RuntimeConfiguration runtimeConfiguration, InstallConfiguration installConfiguration)
{
var path = string.Format(HostPathTemplate, id);
var path = Path.Combine(Options.Value.InstallPath, id);
Directory.CreateDirectory(path);
@@ -35,8 +42,8 @@ public class LocalInstallStorageService : IInstallStorageService
);
}
if(Directory.Exists(localInstallStorage.HostPath))
Directory.Delete(localInstallStorage.HostPath, true);
if(Directory.Exists(localInstallStorage.BindPath))
Directory.Delete(localInstallStorage.BindPath, true);
return Task.CompletedTask;
}