Added 404 handling for backup deletion

This commit is contained in:
Marcel Baumgartner
2023-04-15 22:20:11 +02:00
parent 8c220e6576
commit 9cdf293b7e

View File

@@ -186,8 +186,20 @@ public class ServerService
.Include(x => x.Backups)
.First(x => x.Id == server.Id);
try
{
await WingsApiHelper.Delete(serverData.Node, $"api/servers/{serverData.Uuid}/backup/{serverBackup.Uuid}",
null);
}
catch (WingsException e)
{
// when a backup is not longer there we can
// safely delete the backup so we ignore this error
if (e.StatusCode != 404)
{
throw;
}
}
var backup = serverData.Backups.First(x => x.Uuid == serverBackup.Uuid);
serverData.Backups.Remove(backup);