mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 09:03:49 -07:00
Prevent NullRef when deleting missing backups
(cherry picked from commit 0ff0fe2e68f3abf7b8e4d6bf0c1e9dee4eb68227) Closes #3809
This commit is contained in:
parent
361eb2e53f
commit
e6ceafa03b
1 changed files with 17 additions and 11 deletions
|
@ -20,7 +20,7 @@ namespace Lidarr.Api.V1.System.Backup
|
||||||
private readonly IAppFolderInfo _appFolderInfo;
|
private readonly IAppFolderInfo _appFolderInfo;
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
|
||||||
private static readonly List<string> ValidExtensions = new List<string> { ".zip", ".db", ".xml" };
|
private static readonly List<string> ValidExtensions = new () { ".zip", ".db", ".xml" };
|
||||||
|
|
||||||
public BackupController(IBackupService backupService,
|
public BackupController(IBackupService backupService,
|
||||||
IAppFolderInfo appFolderInfo,
|
IAppFolderInfo appFolderInfo,
|
||||||
|
@ -53,6 +53,12 @@ namespace Lidarr.Api.V1.System.Backup
|
||||||
public void DeleteBackup(int id)
|
public void DeleteBackup(int id)
|
||||||
{
|
{
|
||||||
var backup = GetBackup(id);
|
var backup = GetBackup(id);
|
||||||
|
|
||||||
|
if (backup == null)
|
||||||
|
{
|
||||||
|
throw new NotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
var path = GetBackupPath(backup);
|
var path = GetBackupPath(backup);
|
||||||
|
|
||||||
if (!_diskProvider.FileExists(path))
|
if (!_diskProvider.FileExists(path))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue