Merge pull request #198 from Moonlight-Panel/FixServerDelete
Fixed server delete
This commit is contained in:
@@ -119,7 +119,8 @@ public class ServerService
|
||||
|
||||
var backup = new ServerBackup()
|
||||
{
|
||||
Name = $"Created at {DateTimeService.GetCurrent().ToShortDateString()} {DateTimeService.GetCurrent().ToShortTimeString()}",
|
||||
Name =
|
||||
$"Created at {DateTimeService.GetCurrent().ToShortDateString()} {DateTimeService.GetCurrent().ToShortTimeString()}",
|
||||
Uuid = Guid.NewGuid(),
|
||||
CreatedAt = DateTimeService.GetCurrent(),
|
||||
Created = false
|
||||
@@ -185,8 +186,15 @@ public class ServerService
|
||||
|
||||
try
|
||||
{
|
||||
await WingsApiHelper.Delete(serverData.Node, $"api/servers/{serverData.Uuid}/backup/{serverBackup.Uuid}",
|
||||
await new Retry()
|
||||
.Times(3)
|
||||
.At(x => x.Message.Contains("A task was canceled"))
|
||||
.Call(async () =>
|
||||
{
|
||||
await WingsApiHelper.Delete(serverData.Node,
|
||||
$"api/servers/{serverData.Uuid}/backup/{serverBackup.Uuid}",
|
||||
null);
|
||||
});
|
||||
}
|
||||
catch (WingsException e)
|
||||
{
|
||||
@@ -267,7 +275,8 @@ public class ServerService
|
||||
|
||||
freeAllocations = NodeAllocationRepository
|
||||
.Get()
|
||||
.FromSqlRaw($"SELECT * FROM `NodeAllocations` WHERE ServerId IS NULL AND NodeId={node.Id} LIMIT {allocations}")
|
||||
.FromSqlRaw(
|
||||
$"SELECT * FROM `NodeAllocations` WHERE ServerId IS NULL AND NodeId={node.Id} LIMIT {allocations}")
|
||||
.ToArray();
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -386,8 +395,6 @@ public class ServerService
|
||||
|
||||
public async Task Delete(Server s)
|
||||
{
|
||||
throw new DisplayException("Deleting servers is currently disabled");
|
||||
|
||||
var backups = await GetBackups(s);
|
||||
|
||||
foreach (var backup in backups)
|
||||
@@ -408,7 +415,21 @@ public class ServerService
|
||||
.Include(x => x.Node)
|
||||
.First(x => x.Id == s.Id);
|
||||
|
||||
try
|
||||
{
|
||||
await new Retry()
|
||||
.Times(3)
|
||||
.At(x => x.Message.Contains("A task was canceled"))
|
||||
.Call(async () =>
|
||||
{
|
||||
await WingsApiHelper.Delete(server.Node, $"api/servers/{server.Uuid}", null);
|
||||
});
|
||||
}
|
||||
catch (WingsException e)
|
||||
{
|
||||
if (e.StatusCode != 404)
|
||||
throw;
|
||||
}
|
||||
|
||||
foreach (var variable in server.Variables.ToArray())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user