Update issue #392
Status: Fixed There is now a more consistent parsing of boolean commandline parameters. git-svn-id: https://duplicati.googlecode.com/svn/trunk@918 59da171f-624f-0410-aa54-27559c288bec
This commit is contained in:
@@ -99,10 +99,7 @@ namespace Duplicati.CommandLine.BackendTester
|
||||
else
|
||||
allowedChars += ExtendedChars;
|
||||
|
||||
bool autoCreateFolders = false;
|
||||
string v;
|
||||
if (options.TryGetValue("auto-create-folder", out v))
|
||||
autoCreateFolders = Library.Utility.Utility.ParseBool(v, true);
|
||||
bool autoCreateFolders = Library.Utility.Utility.ParseBoolOption(options, "auto-create-folder");
|
||||
|
||||
Library.Interface.IBackend backend = Library.DynamicLoader.BackendLoader.GetBackend(args[0], options);
|
||||
if (backend == null)
|
||||
@@ -139,8 +136,8 @@ namespace Duplicati.CommandLine.BackendTester
|
||||
foreach (Library.Interface.IFileEntry fe in curlist)
|
||||
if (!fe.IsFolder)
|
||||
{
|
||||
if (options.ContainsKey("auto-clean") && first)
|
||||
if (options.ContainsKey("force"))
|
||||
if (Library.Utility.Utility.ParseBoolOption(options, "auto-clean") && first)
|
||||
if (Library.Utility.Utility.ParseBoolOption(options, "force"))
|
||||
{
|
||||
Console.WriteLine("Auto clean, removing file: {0}", fe.Name);
|
||||
backend.Delete(fe.Name);
|
||||
@@ -159,7 +156,7 @@ namespace Duplicati.CommandLine.BackendTester
|
||||
int max_file_size = 1024 * 1024 * 50;
|
||||
int min_filename_size = 5;
|
||||
int max_filename_size = 80;
|
||||
bool disableStreaming = options.ContainsKey("disable-streaming-transfers");
|
||||
bool disableStreaming = Library.Utility.Utility.ParseBoolOption(options, "disable-streaming-transfers");
|
||||
|
||||
if (options.ContainsKey("number-of-files"))
|
||||
number_of_files = int.Parse(options["number-of-files"]);
|
||||
|
||||
@@ -503,18 +503,18 @@ namespace Duplicati.GUI
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.ContainsKey("full"))
|
||||
if (Library.Utility.Utility.ParseBoolOption(options, "full"))
|
||||
Program.WorkThread.AddTask(new FullBackupTask(schedules[0]));
|
||||
else
|
||||
Program.WorkThread.AddTask(new IncrementalBackupTask(schedules[0]));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.ContainsKey("show-status"))
|
||||
if (Library.Utility.Utility.ParseBoolOption(options, "show-status"))
|
||||
ShowStatus();
|
||||
|
||||
//Resume if requested
|
||||
if (options.ContainsKey("resume"))
|
||||
if (Library.Utility.Utility.ParseBoolOption(options, "resume"))
|
||||
Program.LiveControl.Resume();
|
||||
|
||||
return false;
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace Duplicati.GUI
|
||||
//debug mode uses a lock file located in the app folder
|
||||
Environment.SetEnvironmentVariable(DATAFOLDER_ENV_NAME, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
|
||||
#else
|
||||
bool portableMode = commandlineOptions.ContainsKey("portable-mode") ? Library.Utility.Utility.ParseBool(commandlineOptions["portable-mode"], true) : false;
|
||||
bool portableMode = Library.Utility.Utility.ParseBoolOption(commandlineOptions, "portable-mode");
|
||||
|
||||
if (portableMode)
|
||||
{
|
||||
@@ -244,9 +244,10 @@ namespace Duplicati.GUI
|
||||
|
||||
#if DEBUG
|
||||
//Default is to not use encryption for debugging
|
||||
Program.UseDatabaseEncryption = commandlineOptions.ContainsKey("unencrypted-database") ? !Library.Utility.Utility.ParseBool(commandlineOptions["unencrypted-database"], true) : false;
|
||||
Program.UseDatabaseEncryption = !Library.Utility.Utility.ParseBoolOption(commandlineOptions, "unencrypted-database");
|
||||
#else
|
||||
Program.UseDatabaseEncryption = commandlineOptions.ContainsKey("unencrypted-database") ? !Library.Utility.Utility.ParseBool(commandlineOptions["unencrypted-database"], true) : true;
|
||||
//Default is to use encryption for release
|
||||
Program.UseDatabaseEncryption = !(commandlineOptions.ContainsKey("unencrypted-database") ? Library.Utility.Utility.ParseBoolOption(commandlineOptions, "unencrypted-database") : true);
|
||||
#endif
|
||||
con.ConnectionString = "Data Source=" + DatabasePath;
|
||||
|
||||
|
||||
@@ -78,12 +78,7 @@ namespace Duplicati.Library.Backend
|
||||
}
|
||||
}
|
||||
|
||||
string sslString;
|
||||
if (options.TryGetValue("use-ssl", out sslString))
|
||||
m_useSSL = Utility.Utility.ParseBool(sslString, true);
|
||||
else
|
||||
m_useSSL = false;
|
||||
|
||||
m_useSSL = Utility.Utility.ParseBoolOption(m_options, "use-ssl");
|
||||
|
||||
m_options = options;
|
||||
m_url = url;
|
||||
@@ -293,9 +288,9 @@ namespace Duplicati.Library.Backend
|
||||
req.Credentials = m_userInfo;
|
||||
req.KeepAlive = false;
|
||||
|
||||
if (m_options.ContainsKey("ftp-passive"))
|
||||
if (Utility.Utility.ParseBoolOption(m_options, "ftp-passive"))
|
||||
req.UsePassive = true;
|
||||
if (m_options.ContainsKey("ftp-regular"))
|
||||
if (Utility.Utility.ParseBoolOption(m_options, "ftp-regular"))
|
||||
req.UsePassive = false;
|
||||
|
||||
if (m_useSSL)
|
||||
|
||||
@@ -126,13 +126,7 @@ namespace Duplicati.Library.Backend
|
||||
throw new Exception(string.Format(Strings.FileBackend.NoDestinationWithMarkerFileError, markerfile, string.Join(System.IO.Path.PathSeparator.ToString(), paths.ToArray())));
|
||||
}
|
||||
|
||||
|
||||
string tmp;
|
||||
m_moveFile = false;
|
||||
|
||||
if (options.TryGetValue(OPTION_MOVE_FILE, out tmp))
|
||||
m_moveFile = Utility.Utility.ParseBool(tmp, true);
|
||||
|
||||
m_moveFile = Utility.Utility.ParseBoolOption(options, OPTION_MOVE_FILE);
|
||||
m_hasAutenticated = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,9 @@ namespace Duplicati.Library.Backend
|
||||
|
||||
m_path = u.AbsolutePath;
|
||||
|
||||
if (options.ContainsKey(USE_UNMANAGED_OPTION))
|
||||
m_useManaged = false;
|
||||
m_useManaged = !Utility.Utility.ParseBoolOption(options, USE_UNMANAGED_OPTION);
|
||||
|
||||
if (options.ContainsKey(SSH_NO_CD_OPTION))
|
||||
m_noCdCommand = true;
|
||||
m_noCdCommand = Utility.Utility.ParseBoolOption(options, SSH_NO_CD_OPTION);
|
||||
|
||||
if (m_isLinux)
|
||||
{
|
||||
@@ -146,7 +144,7 @@ namespace Duplicati.Library.Backend
|
||||
else
|
||||
m_transfer_timeout = 1000 * 60 * 15;
|
||||
|
||||
m_write_log_info = options.ContainsKey("debug-to-console");
|
||||
m_write_log_info = Utility.Utility.ParseBoolOption(options, "debug-to-console");
|
||||
}
|
||||
|
||||
#region IBackendInterface Members
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Disclaimer / License
|
||||
#region Disclaimer / License
|
||||
// Copyright (C) 2011, Kenneth Skovhede
|
||||
// http://www.hexad.dk, opensource@hexad.dk
|
||||
//
|
||||
@@ -50,11 +50,7 @@ namespace Duplicati.Library.Backend
|
||||
if (!string.IsNullOrEmpty(u.Query))
|
||||
throw new Exception(Strings.TahoeBackend.UriHasQueryError);
|
||||
|
||||
string sslString;
|
||||
if (options.TryGetValue("use-ssl", out sslString))
|
||||
m_useSSL = Utility.Utility.ParseBool(sslString, true);
|
||||
else
|
||||
m_useSSL = false;
|
||||
m_useSSL = Utility.Utility.ParseBoolOption(m_options, "use-ssl");
|
||||
|
||||
m_options = options;
|
||||
|
||||
|
||||
@@ -86,13 +86,9 @@ namespace Duplicati.Library.Backend
|
||||
}
|
||||
|
||||
m_options = options;
|
||||
m_useIntegratedAuthentication = m_options.ContainsKey("integrated-authentication");
|
||||
m_forceDigestAuthentication = m_options.ContainsKey("force-digest-authentication");
|
||||
string sslString;
|
||||
if (m_options.TryGetValue("use-ssl", out sslString))
|
||||
m_useSSL = Utility.Utility.ParseBool(sslString, true);
|
||||
else
|
||||
m_useSSL = false;
|
||||
m_useIntegratedAuthentication = Utility.Utility.ParseBoolOption(m_options, "integrated-authentication");
|
||||
m_forceDigestAuthentication = Utility.Utility.ParseBoolOption(m_options, "force-digest-authentication");
|
||||
m_useSSL = Utility.Utility.ParseBoolOption(m_options, "use-ssl");
|
||||
|
||||
m_url = (m_useSSL ? "https" : "http") + url.Substring(u.Scheme.Length);
|
||||
if (!m_url.EndsWith("/"))
|
||||
|
||||
@@ -60,9 +60,7 @@ namespace Duplicati.Library.Encryption
|
||||
/// <param name="key">The key used for encryption. The key gets stretched through SHA hashing to fit the key size requirements</param>
|
||||
public AESEncryption(string passphrase, Dictionary<string, string> options)
|
||||
{
|
||||
if (options.ContainsKey(COMMAND_LINE_NO_FALLBACK))
|
||||
m_allowFallback = !Utility.Utility.ParseBool(options[COMMAND_LINE_NO_FALLBACK], true);
|
||||
|
||||
m_allowFallback = !Utility.Utility.ParseBoolOption(options, COMMAND_LINE_NO_FALLBACK);
|
||||
m_key = passphrase;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,9 +129,11 @@ namespace Duplicati.Library.Encryption
|
||||
//NOTE: For reasons unknown, GPG commandline options are divided into "options" and "commands".
|
||||
//NOTE: The "options" must be placed before "commands" or it wont work!
|
||||
|
||||
//Special handling of this option, it should have been --enable-armor instead
|
||||
bool disableArmor = true;
|
||||
|
||||
if (options.ContainsKey(COMMANDLINE_OPTIONS_DISABLE_ARMOR))
|
||||
disableArmor = Utility.Utility.ParseBool(options[COMMANDLINE_OPTIONS_DISABLE_ARMOR], true);
|
||||
Utility.Utility.ParseBoolOption(options, COMMANDLINE_OPTIONS_DISABLE_ARMOR);
|
||||
|
||||
if (!disableArmor)
|
||||
{
|
||||
|
||||
@@ -976,11 +976,7 @@ namespace Duplicati.Library.Main
|
||||
/// <returns>The interpreted value of the option</returns>
|
||||
private bool GetBool(string name)
|
||||
{
|
||||
string value;
|
||||
if (m_options.TryGetValue(name, out value))
|
||||
return Utility.Utility.ParseBool(value, true);
|
||||
else
|
||||
return false;
|
||||
return Utility.Utility.ParseBoolOption(m_options, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,15 +73,15 @@ namespace Duplicati.Library.Modules.Builtin
|
||||
{
|
||||
m_dispose = true;
|
||||
|
||||
bool accepAllCertificates = commandlineOptions.ContainsKey(OPTION_ACCEPT_ANY_CERTIFICATE) && Utility.Utility.ParseBool(commandlineOptions[OPTION_ACCEPT_ANY_CERTIFICATE], true);
|
||||
bool accepAllCertificates = Utility.Utility.ParseBoolOption(commandlineOptions, OPTION_ACCEPT_ANY_CERTIFICATE);
|
||||
|
||||
string certHash;
|
||||
commandlineOptions.TryGetValue(OPTION_ACCEPT_SPECIFIED_CERTIFICATE, out certHash);
|
||||
|
||||
m_certificateValidator = new Library.Utility.SslCertificateValidator(accepAllCertificates, certHash);
|
||||
|
||||
bool disableNagle = commandlineOptions.ContainsKey(OPTION_DISABLE_NAGLING) && Utility.Utility.ParseBool(commandlineOptions[OPTION_DISABLE_NAGLING], true);
|
||||
bool disableExpect100 = commandlineOptions.ContainsKey(OPTION_DISABLE_EXPECT100) && Utility.Utility.ParseBool(commandlineOptions[OPTION_DISABLE_EXPECT100], true);
|
||||
|
||||
bool disableNagle = Utility.Utility.ParseBoolOption(commandlineOptions, OPTION_DISABLE_NAGLING);
|
||||
bool disableExpect100 = Utility.Utility.ParseBoolOption(commandlineOptions, OPTION_DISABLE_EXPECT100);
|
||||
|
||||
m_useNagle = System.Net.ServicePointManager.UseNagleAlgorithm;
|
||||
m_useExpect = System.Net.ServicePointManager.Expect100Continue;
|
||||
|
||||
@@ -78,7 +78,7 @@ Where <test-folder> is the folder where files will be locked/created etc");
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.ContainsKey("usn-test"))
|
||||
if (Library.Utility.Utility.ParseBoolOption(options, "usn-test"))
|
||||
{
|
||||
using (USNHelper usn = new USNHelper(args[0]))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user