sonarr-repo-only/NzbDrone.Update/UpdateEngine/BackupAndRestore.cs

39 lines
1.2 KiB
C#
Raw Normal View History

2013-05-21 04:03:05 +00:00
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
2013-05-21 04:03:05 +00:00
namespace NzbDrone.Update.UpdateEngine
{
public interface IBackupAndRestore
{
void BackUp(string source);
void Restore(string target);
}
public class BackupAndRestore : IBackupAndRestore
{
private readonly IDiskProvider _diskProvider;
private readonly IAppDirectoryInfo _appDirectoryInfo;
2013-05-21 04:03:05 +00:00
private readonly Logger _logger;
public BackupAndRestore(IDiskProvider diskProvider, IAppDirectoryInfo appDirectoryInfo, Logger logger)
2013-05-21 04:03:05 +00:00
{
_diskProvider = diskProvider;
_appDirectoryInfo = appDirectoryInfo;
2013-05-21 04:03:05 +00:00
_logger = logger;
}
public void BackUp(string source)
{
_logger.Info("Creating backup of existing installation");
_diskProvider.CopyDirectory(source, _appDirectoryInfo.GetUpdateBackUpFolder());
2013-05-21 04:03:05 +00:00
}
public void Restore(string target)
{
//TODO:this should ignore single file failures.
_logger.Info("Attempting to rollback upgrade");
_diskProvider.CopyDirectory(_appDirectoryInfo.GetUpdateBackUpFolder(), target);
2013-05-21 04:03:05 +00:00
}
}
}