Implemented statistics. Refactored storage abstractions. Added config options for docker and local storage. Added server service and server updating.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user