Check if backup folder is writable on backup

(cherry picked from commit 8aad79fd3e14eb885724a5e5790803c289be2f25)

Closes #3961
This commit is contained in:
Bogdan
2024-12-30 04:09:48 +02:00
parent c1b26eec8d
commit a550c6554f
2 changed files with 19 additions and 11 deletions

View File

@@ -42,8 +42,10 @@ namespace NzbDrone.Common
public void CreateZip(string path, IEnumerable<string> files)
{
using (var zipFile = ZipFile.Create(path))
{
_logger.Debug("Creating archive {0}", path);
using var zipFile = ZipFile.Create(path);
zipFile.BeginUpdate();
foreach (var file in files)
@@ -53,7 +55,6 @@ namespace NzbDrone.Common
zipFile.CommitUpdate();
}
}
private void ExtractZip(string compressedFile, string destination)
{

View File

@@ -66,12 +66,19 @@ namespace NzbDrone.Core.Backup
{
_logger.ProgressInfo("Starting Backup");
var backupFolder = GetBackupFolder(backupType);
_diskProvider.EnsureFolder(_backupTempFolder);
_diskProvider.EnsureFolder(GetBackupFolder(backupType));
_diskProvider.EnsureFolder(backupFolder);
if (!_diskProvider.FolderWritable(backupFolder))
{
throw new UnauthorizedAccessException($"Backup folder {backupFolder} is not writable");
}
var dateNow = DateTime.Now;
var backupFilename = $"readarr_backup_v{BuildInfo.Version}_{dateNow:yyyy.MM.dd_HH.mm.ss}.zip";
var backupPath = Path.Combine(GetBackupFolder(backupType), backupFilename);
var backupPath = Path.Combine(backupFolder, backupFilename);
Cleanup();