From 2d9c77ec5eccd6a2f75b9d6eadc17902838a4ccd Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 1 Dec 2020 21:46:49 -0500 Subject: [PATCH] Fixed: If v0.2 DB Exists back it up during update --- src/NzbDrone.Common/Extensions/PathExtensions.cs | 11 +++++++++++ src/NzbDrone.Update/UpdateEngine/BackupAppData.cs | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index 49b1fbc72..335a0502e 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -12,6 +12,7 @@ namespace NzbDrone.Common.Extensions { private const string APP_CONFIG_FILE = "config.xml"; private const string DB = "radarr.db"; + private const string DB_OLD = "nzbdrone.db"; private const string DB_RESTORE = "radarr.restore"; private const string LOG_DB = "logs.db"; private const string NLOG_CONFIG_FILE = "nlog.config"; @@ -303,6 +304,11 @@ namespace NzbDrone.Common.Extensions return Path.Combine(GetUpdateBackUpAppDataFolder(appFolderInfo), DB); } + public static string GetV0UpdateBackupDatabase(this IAppFolderInfo appFolderInfo) + { + return Path.Combine(GetUpdateBackUpAppDataFolder(appFolderInfo), DB_OLD); + } + public static string GetUpdatePackageFolder(this IAppFolderInfo appFolderInfo) { return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_PACKAGE_FOLDER_NAME); @@ -323,6 +329,11 @@ namespace NzbDrone.Common.Extensions return Path.Combine(GetAppDataPath(appFolderInfo), DB); } + public static string GetV0Database(this IAppFolderInfo appFolderInfo) + { + return Path.Combine(GetAppDataPath(appFolderInfo), DB_OLD); + } + public static string GetDatabaseRestore(this IAppFolderInfo appFolderInfo) { return Path.Combine(GetAppDataPath(appFolderInfo), DB_RESTORE); diff --git a/src/NzbDrone.Update/UpdateEngine/BackupAppData.cs b/src/NzbDrone.Update/UpdateEngine/BackupAppData.cs index 1a58b57d7..991c7d6c1 100644 --- a/src/NzbDrone.Update/UpdateEngine/BackupAppData.cs +++ b/src/NzbDrone.Update/UpdateEngine/BackupAppData.cs @@ -46,7 +46,16 @@ namespace NzbDrone.Update.UpdateEngine try { _diskTransferService.TransferFile(_appFolderInfo.GetConfigPath(), _appFolderInfo.GetUpdateBackupConfigFile(), TransferMode.Copy); - _diskTransferService.TransferFile(_appFolderInfo.GetDatabase(), _appFolderInfo.GetUpdateBackupDatabase(), TransferMode.Copy); + + //Backup new db if exists, else try old then fail + if (_diskProvider.FileExists(_appFolderInfo.GetDatabase())) + { + _diskTransferService.TransferFile(_appFolderInfo.GetDatabase(), _appFolderInfo.GetUpdateBackupDatabase(), TransferMode.Copy); + } + else + { + _diskTransferService.TransferFile(_appFolderInfo.GetV0Database(), _appFolderInfo.GetV0UpdateBackupDatabase(), TransferMode.Copy); + } } catch (Exception e) {