sonarr-repo-only/NzbDrone.Core/Providers/BackupProvider.cs

37 lines
842 B
C#
Raw Normal View History

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