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