|
|
@ -1,8 +1,5 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Security.AccessControl;
|
|
|
|
|
|
|
|
using System.Security.Principal;
|
|
|
|
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
using NzbDrone.Common.Exceptions;
|
|
|
|
using NzbDrone.Common.Exceptions;
|
|
|
@ -91,8 +88,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_diskProvider.MoveFile(oldDbFile, _appFolderInfo.GetDatabase());
|
|
|
|
MoveSqliteDatabase(oldDbFile, _appFolderInfo.GetDatabase());
|
|
|
|
CleanupSqLiteRollbackFiles();
|
|
|
|
|
|
|
|
RemovePidFile();
|
|
|
|
RemovePidFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -105,12 +101,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();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -159,12 +152,37 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CleanupSqLiteRollbackFiles()
|
|
|
|
private void MoveSqliteDatabase(string source, string destination)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_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.GetFiles(_appFolderInfo.AppDataFolder, SearchOption.TopDirectoryOnly)
|
|
|
|
_diskProvider.CopyFile(sourceFile, destFile);
|
|
|
|
.Where(f => Path.GetFileName(f).StartsWith("nzbdrone.db"))
|
|
|
|
}
|
|
|
|
.ToList()
|
|
|
|
}
|
|
|
|
.ForEach(_diskProvider.DeleteFile);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var suffix in dbSuffixes)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var sourceFile = source + suffix;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_diskProvider.FileExists(sourceFile))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_diskProvider.DeleteFile(sourceFile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void RemovePidFile()
|
|
|
|
private void RemovePidFile()
|
|
|
|