2013-05-21 07:03:05 +03:00
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common;
|
2013-06-28 03:04:52 +03:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-05-21 07:03:05 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Update.UpdateEngine
|
|
|
|
{
|
|
|
|
public interface IBackupAndRestore
|
|
|
|
{
|
|
|
|
void BackUp(string source);
|
|
|
|
void Restore(string target);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class BackupAndRestore : IBackupAndRestore
|
|
|
|
{
|
|
|
|
private readonly IDiskProvider _diskProvider;
|
2013-07-05 07:43:28 +03:00
|
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
2013-05-21 07:03:05 +03:00
|
|
|
private readonly Logger _logger;
|
|
|
|
|
2013-07-05 07:43:28 +03:00
|
|
|
public BackupAndRestore(IDiskProvider diskProvider, IAppFolderInfo appFolderInfo, Logger logger)
|
2013-05-21 07:03:05 +03:00
|
|
|
{
|
|
|
|
_diskProvider = diskProvider;
|
2013-07-05 07:43:28 +03:00
|
|
|
_appFolderInfo = appFolderInfo;
|
2013-05-21 07:03:05 +03:00
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void BackUp(string source)
|
|
|
|
{
|
|
|
|
_logger.Info("Creating backup of existing installation");
|
2013-07-05 07:43:28 +03:00
|
|
|
_diskProvider.CopyFolder(source, _appFolderInfo.GetUpdateBackUpFolder());
|
2013-05-21 07:03:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Restore(string target)
|
|
|
|
{
|
|
|
|
_logger.Info("Attempting to rollback upgrade");
|
2013-07-05 07:43:28 +03:00
|
|
|
_diskProvider.CopyFolder(_appFolderInfo.GetUpdateBackUpFolder(), target);
|
2013-05-21 07:03:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|