namespace MoonlightServers.Daemon.ServerSystem; public partial class Server { public async Task DeleteAsync() { await Lock.WaitAsync(); try { if(State != ServerState.Offline) throw new InvalidOperationException("Server is not offline"); Logger.LogTrace("Deleting"); InstallStorage ??= await InstallStorageService.FindAsync(Uuid); if (InstallStorage != null) { Logger.LogTrace("Deleting install storage"); await InstallStorageService.DeleteAsync(InstallStorage); } RuntimeStorage ??= await RuntimeStorageService.FindAsync(Uuid); if (RuntimeStorage != null) { Logger.LogTrace("Deleting runtime storage"); await RuntimeStorageService.DeleteAsync(RuntimeStorage); } } finally { Lock.Release(); } } }