Recreated plugin with new project template. Started implementing server system daemon
This commit is contained in:
37
MoonlightServers.Daemon/ServerSystem/Server.Delete.cs
Normal file
37
MoonlightServers.Daemon/ServerSystem/Server.Delete.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user