2012-01-27 08:05:09 +03:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using Ionic.Zip;
|
|
|
|
using NzbDrone.Common;
|
2013-06-28 03:04:52 +03:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2012-01-27 08:05:09 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
|
|
{
|
|
|
|
public class BackupProvider
|
|
|
|
{
|
2013-06-28 03:04:52 +03:00
|
|
|
private readonly IAppDirectoryInfo _appDirectoryInfo;
|
|
|
|
|
|
|
|
public BackupProvider(IAppDirectoryInfo appDirectoryInfo)
|
2012-01-27 08:05:09 +03:00
|
|
|
{
|
2013-06-28 03:04:52 +03:00
|
|
|
_appDirectoryInfo = appDirectoryInfo;
|
2012-01-27 08:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public BackupProvider()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual string CreateBackupZip()
|
|
|
|
{
|
2013-06-28 03:04:52 +03:00
|
|
|
var configFile = _appDirectoryInfo.GetConfigPath();
|
|
|
|
var zipFile = _appDirectoryInfo.GetConfigBackupFile();
|
2012-01-27 08:05:09 +03:00
|
|
|
|
2012-01-27 08:24:41 +03:00
|
|
|
using (var zip = new ZipFile())
|
2012-01-27 08:05:09 +03:00
|
|
|
{
|
2012-01-27 08:24:41 +03:00
|
|
|
zip.AddFile(configFile, String.Empty);
|
|
|
|
zip.Save(zipFile);
|
2012-01-27 08:05:09 +03:00
|
|
|
}
|
2012-01-27 08:24:41 +03:00
|
|
|
|
|
|
|
return zipFile;
|
2012-01-27 08:05:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|