Add support for choosing compression algorithm.

This commit is contained in:
2017-05-11 03:46:19 +01:00
parent f7e5facc0e
commit 247e4ec4f4
7 changed files with 137 additions and 15 deletions

View File

@@ -1,3 +1,9 @@
2017-05-11 Natalia Portillo <claunia@claunia.com>
* Workers.cs:
* Settings.cs:
Add support for choosing compression algorithm.
2017-05-11 Natalia Portillo <claunia@claunia.com>
* Workers.cs:

View File

@@ -31,6 +31,7 @@ using System.IO;
using System.Xml.Serialization;
using Claunia.PropertyList;
using Microsoft.Win32;
using Ionic.Zip;
namespace osrepodbmgr.Core
{
@@ -40,6 +41,7 @@ namespace osrepodbmgr.Core
public string DatabasePath;
public string RepositoryPath;
public string UnArchiverPath;
public CompressionMethod CompressionAlgorithm;
}
public static class Settings
@@ -100,6 +102,13 @@ namespace osrepodbmgr.Core
else
Current.UnArchiverPath = null;
if(parsedPreferences.TryGetValue("CompressionAlgorithm", out obj))
{
if(!Enum.TryParse(((NSString)obj).ToString(), true, out Current.CompressionAlgorithm))
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
else
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
else {
SetDefaultSettings();
@@ -133,6 +142,8 @@ namespace osrepodbmgr.Core
Current.DatabasePath = (string)key.GetValue("DatabasePath");
Current.RepositoryPath = (string)key.GetValue("RepositoryPath");
Current.UnArchiverPath = (string)key.GetValue("UnArchiverPath");
if(!Enum.TryParse((string)key.GetValue("CompressionAlgorithm"), true, out Current.CompressionAlgorithm))
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
break;
default:
@@ -178,6 +189,7 @@ namespace osrepodbmgr.Core
root.Add("DatabasePath", Current.DatabasePath);
root.Add("RepositoryPath", Current.RepositoryPath);
root.Add("UnArchiverPath", Current.UnArchiverPath);
root.Add("CompressionAlgorithm", Current.CompressionAlgorithm);
string preferencesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Preferences");
string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.museum.osrepodbmgr.plist");
@@ -200,6 +212,7 @@ namespace osrepodbmgr.Core
key.SetValue("DatabasePath", Current.DatabasePath);
key.SetValue("RepositoryPath", Current.RepositoryPath);
key.SetValue("UnArchiverPath", Current.UnArchiverPath);
key.SetValue("CompressionAlgorithm", Current.CompressionAlgorithm);
}
break;
default:
@@ -234,6 +247,7 @@ namespace osrepodbmgr.Core
Current.DatabasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "osrepodbmgr.db");
Current.RepositoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "osrepo");
Current.UnArchiverPath = null;
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
}
}

View File

@@ -831,7 +831,7 @@ namespace osrepodbmgr.Core
ZipFile zf = new ZipFile(destination);
zf.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
zf.CompressionMethod = CompressionMethod.Deflate;
zf.CompressionMethod = Settings.Current.CompressionAlgorithm;
zf.UseZip64WhenSaving = Zip64Option.AsNecessary;
string filesPath;