Don't ignore original wal/journal during v3 migration
This commit is contained in:
parent
34faa417c1
commit
fa8b2f48e7
|
@ -85,8 +85,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
||||||
if (_diskProvider.FileExists(_appFolderInfo.GetDatabase())) return;
|
if (_diskProvider.FileExists(_appFolderInfo.GetDatabase())) return;
|
||||||
if (!_diskProvider.FileExists(oldDbFile)) return;
|
if (!_diskProvider.FileExists(oldDbFile)) return;
|
||||||
|
|
||||||
_diskProvider.MoveFile(oldDbFile, _appFolderInfo.GetDatabase());
|
MoveSqliteDatabase(oldDbFile, _appFolderInfo.GetDatabase());
|
||||||
CleanupSqLiteRollbackFiles();
|
|
||||||
RemovePidFile();
|
RemovePidFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,12 +107,9 @@ namespace NzbDrone.Common.EnvironmentInfo
|
||||||
// Rename the DB file
|
// Rename the DB file
|
||||||
if (_diskProvider.FileExists(oldDbFile))
|
if (_diskProvider.FileExists(oldDbFile))
|
||||||
{
|
{
|
||||||
_diskProvider.MoveFile(oldDbFile, _appFolderInfo.GetDatabase());
|
MoveSqliteDatabase(oldDbFile, _appFolderInfo.GetDatabase());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove SQLite rollback files
|
|
||||||
CleanupSqLiteRollbackFiles();
|
|
||||||
|
|
||||||
// Remove Old PID file
|
// Remove Old PID file
|
||||||
RemovePidFile();
|
RemovePidFile();
|
||||||
|
|
||||||
|
@ -127,7 +123,6 @@ namespace NzbDrone.Common.EnvironmentInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void InitializeMonoApplicationData()
|
private void InitializeMonoApplicationData()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsWindows) return;
|
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)
|
_logger.Info("Moving {0}* to {1}*", source, destination);
|
||||||
.Where(f => Path.GetFileName(f).StartsWith("nzbdrone.db"))
|
|
||||||
.ToList()
|
var dbSuffixes = new[] { "", "-shm", "-wal", "-journal" };
|
||||||
.ForEach(_diskProvider.DeleteFile);
|
|
||||||
|
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()
|
private void RemovePidFile()
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
{
|
{
|
||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
|
|
||||||
_announcer.Heading("Migrating " + connectionString);
|
_announcer.Heading("Checking database for required migrations " + connectionString);
|
||||||
|
|
||||||
var assembly = Assembly.GetExecutingAssembly();
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue