Don't ignore original wal/journal during v3 migration

pull/4397/head
Taloth Saldono 4 years ago
parent 34faa417c1
commit fa8b2f48e7

@ -85,8 +85,7 @@ namespace NzbDrone.Common.EnvironmentInfo
if (_diskProvider.FileExists(_appFolderInfo.GetDatabase())) return;
if (!_diskProvider.FileExists(oldDbFile)) return;
_diskProvider.MoveFile(oldDbFile, _appFolderInfo.GetDatabase());
CleanupSqLiteRollbackFiles();
MoveSqliteDatabase(oldDbFile, _appFolderInfo.GetDatabase());
RemovePidFile();
}
@ -108,12 +107,9 @@ namespace NzbDrone.Common.EnvironmentInfo
// Rename the DB file
if (_diskProvider.FileExists(oldDbFile))
{
_diskProvider.MoveFile(oldDbFile, _appFolderInfo.GetDatabase());
MoveSqliteDatabase(oldDbFile, _appFolderInfo.GetDatabase());
}
// Remove SQLite rollback files
CleanupSqLiteRollbackFiles();
// Remove Old PID file
RemovePidFile();
@ -127,7 +123,6 @@ namespace NzbDrone.Common.EnvironmentInfo
}
}
private void InitializeMonoApplicationData()
{
if (OsInfo.IsWindows) return;
@ -158,12 +153,37 @@ namespace NzbDrone.Common.EnvironmentInfo
}
}
private void CleanupSqLiteRollbackFiles()
private void MoveSqliteDatabase(string source, string destination)
{
_diskProvider.GetFiles(_appFolderInfo.AppDataFolder, SearchOption.TopDirectoryOnly)
.Where(f => Path.GetFileName(f).StartsWith("nzbdrone.db"))
.ToList()
.ForEach(_diskProvider.DeleteFile);
_logger.Info("Moving {0}* to {1}*", source, destination);
var dbSuffixes = new[] { "", "-shm", "-wal", "-journal" };
foreach (var suffix in dbSuffixes)
{
var sourceFile = source + suffix;
var destFile = destination + suffix;
if (_diskProvider.FileExists(destFile))
{
_diskProvider.DeleteFile(destFile);
}
if (_diskProvider.FileExists(sourceFile))
{
_diskProvider.CopyFile(sourceFile, destFile);
}
}
foreach (var suffix in dbSuffixes)
{
var sourceFile = source + suffix;
if (_diskProvider.FileExists(sourceFile))
{
_diskProvider.DeleteFile(sourceFile);
}
}
}
private void RemovePidFile()

@ -24,7 +24,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
{
var sw = Stopwatch.StartNew();
_announcer.Heading("Migrating " + connectionString);
_announcer.Heading("Checking database for required migrations " + connectionString);
var assembly = Assembly.GetExecutingAssembly();

Loading…
Cancel
Save