mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Don't ignore original wal/journal during v3 migration
Fixes #6067 Doesn't really apply to us, save for realllly old installs. Co-Authored-By: Taloth <Taloth@users.noreply.github.com>
This commit is contained in:
parent
eb76dd5248
commit
a037a8dbe2
@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
@ -91,8 +88,7 @@ private void MigrateAppDataFolder()
|
||||
return;
|
||||
}
|
||||
|
||||
_diskProvider.MoveFile(oldDbFile, _appFolderInfo.GetDatabase());
|
||||
CleanupSqLiteRollbackFiles();
|
||||
MoveSqliteDatabase(oldDbFile, _appFolderInfo.GetDatabase());
|
||||
RemovePidFile();
|
||||
}
|
||||
|
||||
@ -105,12 +101,9 @@ private void MigrateAppDataFolder()
|
||||
// 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();
|
||||
}
|
||||
@ -159,12 +152,37 @@ private void InitializeMonoApplicationData()
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user