diff --git a/src/Sonarr.Api.V3/System/Backup/BackupController.cs b/src/Sonarr.Api.V3/System/Backup/BackupController.cs index aaae25b01..e811e0bf4 100644 --- a/src/Sonarr.Api.V3/System/Backup/BackupController.cs +++ b/src/Sonarr.Api.V3/System/Backup/BackupController.cs @@ -20,7 +20,7 @@ namespace Sonarr.Api.V3.System.Backup private readonly IAppFolderInfo _appFolderInfo; private readonly IDiskProvider _diskProvider; - private static readonly List ValidExtensions = new List { ".zip", ".db", ".xml" }; + private static readonly List ValidExtensions = new () { ".zip", ".db", ".xml" }; public BackupController(IBackupService backupService, IAppFolderInfo appFolderInfo, @@ -37,22 +37,28 @@ namespace Sonarr.Api.V3.System.Backup var backups = _backupService.GetBackups(); return backups.Select(b => new BackupResource - { - Id = GetBackupId(b), - Name = b.Name, - Path = $"/backup/{b.Type.ToString().ToLower()}/{b.Name}", - Size = b.Size, - Type = b.Type, - Time = b.Time - }) - .OrderByDescending(b => b.Time) - .ToList(); + { + Id = GetBackupId(b), + Name = b.Name, + Path = $"/backup/{b.Type.ToString().ToLower()}/{b.Name}", + Size = b.Size, + Type = b.Type, + Time = b.Time + }) + .OrderByDescending(b => b.Time) + .ToList(); } [RestDeleteById] public void DeleteBackup(int id) { var backup = GetBackup(id); + + if (backup == null) + { + throw new NotFoundException(); + } + var path = GetBackupPath(backup); if (!_diskProvider.FileExists(path))