Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gill <tyler.gill@byu.net>2017-09-19 08:23:45 +0300
committerTyler Gill <tyler.gill@byu.net>2017-09-19 08:55:08 +0300
commit83a1dcfb64104b51e09f17dcf9237a184f7086aa (patch)
treedbe324fbfeb569b7444edef0c031dc40e9abe85d
parent3e0aa28c29b2532d679a5d2f946e31bab5e9bde4 (diff)
Replace all instances of InvariantCultureIgnoreCase with OrdinalIgnoreCase in string comparisons.
InvariantCulture is useful when comparing / sorting human language strings in a culturely correct way. It handles things like accented letters in a way that makes sense to humans (e.g., 'a' should be sorted next to 'รก', rather than after 'z'). Ordinal looks just at the raw code points of the characters. As such, it is recommended for use in cases when comparing system strings (file paths, command line parameters, config settings, etc.). Since it doesn't need to use the culture specific sorting rules, this method can often be faster. For more information, see https://stackoverflow.com/questions/492799/difference-between-invariantculture-and-ordinal-string-comparison (and other related questions)
-rw-r--r--Duplicati/CommandLine/BackendTool/Program.cs12
-rw-r--r--Duplicati/CommandLine/Commands.cs4
-rw-r--r--Duplicati/CommandLine/Help.cs34
-rw-r--r--Duplicati/CommandLine/Program.cs10
-rw-r--r--Duplicati/CommandLine/RecoveryTool/Program.cs6
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/HostedInstanceKeeper.cs2
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs22
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/ImageLoader.cs2
-rw-r--r--Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs38
-rw-r--r--Duplicati/Library/AutoUpdater/AutoUpdateSettings.cs4
-rw-r--r--Duplicati/Library/AutoUpdater/UpdaterManager.cs4
-rw-r--r--Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs4
-rw-r--r--Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs4
-rw-r--r--Duplicati/Library/Backend/Backblaze/B2.cs2
-rw-r--r--Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs2
-rw-r--r--Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs2
-rw-r--r--Duplicati/Library/Backend/OneDrive/OneDrive.cs8
-rw-r--r--Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs2
-rw-r--r--Duplicati/Library/Backend/S3/S3Backend.cs8
-rw-r--r--Duplicati/Library/Backend/S3/S3Wrapper.cs4
-rw-r--r--Duplicati/Library/Backend/SSHv2/KeyGenerator.cs4
-rw-r--r--Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs46
-rw-r--r--Duplicati/Library/Backend/SharePoint/SharePointBackend.cs2
-rw-r--r--Duplicati/Library/Backend/WEBDAV/WEBDAV.cs4
-rw-r--r--Duplicati/Library/DynamicLoader/BackendLoader.cs4
-rw-r--r--Duplicati/Library/Localization/MoLocalizationService.cs2
-rw-r--r--Duplicati/Library/Main/BackendManager.cs52
-rw-r--r--Duplicati/Library/Main/Controller.cs2
-rw-r--r--Duplicati/Library/Main/DatabaseLocator.cs62
-rw-r--r--Duplicati/Library/Main/Options.cs26
-rw-r--r--Duplicati/Library/Main/Volumes/VolumeBase.cs2
-rw-r--r--Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs4
-rw-r--r--Duplicati/Library/Modules/Builtin/RunScript.cs40
-rw-r--r--Duplicati/Library/Modules/Builtin/SendHttpMessage.cs22
-rw-r--r--Duplicati/Library/Modules/Builtin/SendJabberMessage.cs30
-rw-r--r--Duplicati/Library/Modules/Builtin/SendMail.cs28
-rw-r--r--Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs2
-rw-r--r--Duplicati/Library/UsageReporter/OSInfoHelper.cs14
-rw-r--r--Duplicati/Library/UsageReporter/Reporter.cs2
-rw-r--r--Duplicati/Library/Utility/FilterCollector.cs4
-rw-r--r--Duplicati/Library/Utility/SslCertificateValidator.cs2
-rw-r--r--Duplicati/Library/Utility/Uri.cs6
-rw-r--r--Duplicati/Library/Utility/Utility.cs2
-rw-r--r--Duplicati/Server/Database/Connection.cs58
-rw-r--r--Duplicati/Server/Database/Schedule.cs4
-rw-r--r--Duplicati/Server/Program.cs16
-rw-r--r--Duplicati/Server/Runner.cs112
-rw-r--r--Duplicati/Server/SpecialFolders.cs4
-rw-r--r--Duplicati/Server/WebServer/AuthenticationHandler.cs10
-rw-r--r--Duplicati/Server/WebServer/RESTHandler.cs6
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/Backup.cs4
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/Backups.cs8
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/Captcha.cs2
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/CommandLine.cs2
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/Filesystem.cs4
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/LogData.cs90
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/ServerSetting.cs24
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/WebModule.cs17
-rw-r--r--Duplicati/Server/WebServer/Server.cs2
-rw-r--r--Duplicati/Server/WebServer/SynologyAuthenticationHandler.cs264
-rw-r--r--Duplicati/UnitTest/BasicSetupHelper.cs2
61 files changed, 632 insertions, 533 deletions
diff --git a/Duplicati/CommandLine/BackendTool/Program.cs b/Duplicati/CommandLine/BackendTool/Program.cs
index 41c21ac02..2f8054575 100644
--- a/Duplicati/CommandLine/BackendTool/Program.cs
+++ b/Duplicati/CommandLine/BackendTool/Program.cs
@@ -59,17 +59,17 @@ namespace Duplicati.CommandLine.BackendTool
string command = null;
if (args.Count >= 2)
{
- if (args[0].Equals("list", StringComparison.InvariantCultureIgnoreCase))
+ if (args[0].Equals("list", StringComparison.OrdinalIgnoreCase))
command = "list";
- else if (args[0].Equals("get", StringComparison.InvariantCultureIgnoreCase))
+ else if (args[0].Equals("get", StringComparison.OrdinalIgnoreCase))
command = "get";
- else if (args[0].Equals("put", StringComparison.InvariantCultureIgnoreCase))
+ else if (args[0].Equals("put", StringComparison.OrdinalIgnoreCase))
command = "put";
- else if (args[0].Equals("delete", StringComparison.InvariantCultureIgnoreCase))
+ else if (args[0].Equals("delete", StringComparison.OrdinalIgnoreCase))
command = "delete";
- else if (args[0].Equals("create-folder", StringComparison.InvariantCultureIgnoreCase))
+ else if (args[0].Equals("create-folder", StringComparison.OrdinalIgnoreCase))
command = "create";
- else if (args[0].Equals("createfolder", StringComparison.InvariantCultureIgnoreCase))
+ else if (args[0].Equals("createfolder", StringComparison.OrdinalIgnoreCase))
command = "create";
}
diff --git a/Duplicati/CommandLine/Commands.cs b/Duplicati/CommandLine/Commands.cs
index f78c5684d..0ae5f7fcc 100644
--- a/Duplicati/CommandLine/Commands.cs
+++ b/Duplicati/CommandLine/Commands.cs
@@ -385,7 +385,7 @@ namespace Duplicati.CommandLine
{
var requiredOptions = new string[] { "keep-time", "keep-versions", "version" };
- if (!options.Keys.Where(x => requiredOptions.Contains(x, StringComparer.InvariantCultureIgnoreCase)).Any())
+ if (!options.Keys.Where(x => requiredOptions.Contains(x, StringComparer.OrdinalIgnoreCase)).Any())
{
outwriter.WriteLine(Strings.Program.DeleteCommandNeedsOptions("delete", requiredOptions));
return 200;
@@ -643,7 +643,7 @@ namespace Duplicati.CommandLine
var tests = 1L;
if (args.Count == 2)
{
- if (new string[] { "all", "everything" }.Contains(args[1], StringComparer.InvariantCultureIgnoreCase))
+ if (new string[] { "all", "everything" }.Contains(args[1], StringComparer.OrdinalIgnoreCase))
tests = long.MaxValue;
else
tests = Convert.ToInt64(args[1]);
diff --git a/Duplicati/CommandLine/Help.cs b/Duplicati/CommandLine/Help.cs
index 5920078fb..341b77efc 100644
--- a/Duplicati/CommandLine/Help.cs
+++ b/Duplicati/CommandLine/Help.cs
@@ -14,7 +14,7 @@ namespace Duplicati.CommandLine
static Help()
{
- _document = new Dictionary<string,string>(StringComparer.InvariantCultureIgnoreCase);
+ _document = new Dictionary<string,string>(StringComparer.OrdinalIgnoreCase);
using (System.IO.StreamReader sr = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(RESOURCE_NAME)))
{
@@ -38,9 +38,9 @@ namespace Duplicati.CommandLine
}
string[] elems = line.Split(new string[] {" ", "\t"}, StringSplitOptions.RemoveEmptyEntries);
- if (elems.Length >= 2 && string.Equals(elems[elems.Length - 2], "help", StringComparison.InvariantCultureIgnoreCase))
+ if (elems.Length >= 2 && string.Equals(elems[elems.Length - 2], "help", StringComparison.OrdinalIgnoreCase))
keywords.Add(elems[elems.Length - 1]);
- else if (elems.Length == 3 && string.Equals(elems[elems.Length - 1], "help", StringComparison.InvariantCultureIgnoreCase))
+ else if (elems.Length == 3 && string.Equals(elems[elems.Length - 1], "help", StringComparison.OrdinalIgnoreCase))
keywords.Add("help");
}
else
@@ -76,13 +76,13 @@ namespace Duplicati.CommandLine
if (string.IsNullOrWhiteSpace(topic))
topic = "help";
- if (string.Equals("help", topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals("help", topic, StringComparison.OrdinalIgnoreCase))
{
if (options.Count == 1)
topic = new List<string>(options.Keys)[0];
- else if (System.Environment.CommandLine.IndexOf("--exclude", StringComparison.InvariantCultureIgnoreCase) >= 0)
+ else if (System.Environment.CommandLine.IndexOf("--exclude", StringComparison.OrdinalIgnoreCase) >= 0)
topic = "exclude";
- else if (System.Environment.CommandLine.IndexOf("--include", StringComparison.InvariantCultureIgnoreCase) >= 0)
+ else if (System.Environment.CommandLine.IndexOf("--include", StringComparison.OrdinalIgnoreCase) >= 0)
topic = "include";
}
@@ -186,7 +186,7 @@ namespace Duplicati.CommandLine
IList<Library.Interface.ICommandLineArgument> args = null;
bool found = false;
foreach (Duplicati.Library.Interface.IBackend backend in Library.DynamicLoader.BackendLoader.Backends)
- if (string.Equals(backend.ProtocolKey, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(backend.ProtocolKey, topic, StringComparison.OrdinalIgnoreCase))
{
args = backend.SupportedCommands;
found = true;
@@ -195,7 +195,7 @@ namespace Duplicati.CommandLine
if (args == null)
foreach (Duplicati.Library.Interface.IEncryption module in Library.DynamicLoader.EncryptionLoader.Modules)
- if (string.Equals(module.FilenameExtension, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(module.FilenameExtension, topic, StringComparison.OrdinalIgnoreCase))
{
args = module.SupportedCommands;
found = true;
@@ -204,7 +204,7 @@ namespace Duplicati.CommandLine
if (args == null)
foreach (Duplicati.Library.Interface.ICompression module in Library.DynamicLoader.CompressionLoader.Modules)
- if (string.Equals(module.FilenameExtension, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(module.FilenameExtension, topic, StringComparison.OrdinalIgnoreCase))
{
args = module.SupportedCommands;
found = true;
@@ -213,7 +213,7 @@ namespace Duplicati.CommandLine
if (args == null)
foreach (Duplicati.Library.Interface.IGenericModule module in Library.DynamicLoader.GenericLoader.Modules)
- if (string.Equals(module.Key, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(module.Key, topic, StringComparison.OrdinalIgnoreCase))
{
args = module.SupportedCommands;
found = true;
@@ -244,7 +244,7 @@ namespace Duplicati.CommandLine
List<string> lines = new List<string>();
foreach (Duplicati.Library.Interface.IBackend backend in Library.DynamicLoader.BackendLoader.Backends)
- if (string.Equals(backend.ProtocolKey, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(backend.ProtocolKey, topic, StringComparison.OrdinalIgnoreCase))
{
PrintBackend(backend, lines);
break;
@@ -252,7 +252,7 @@ namespace Duplicati.CommandLine
if (lines.Count == 0)
foreach (Duplicati.Library.Interface.IEncryption mod in Library.DynamicLoader.EncryptionLoader.Modules)
- if (string.Equals(mod.FilenameExtension, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(mod.FilenameExtension, topic, StringComparison.OrdinalIgnoreCase))
{
PrintEncryptionModule(mod, lines);
break;
@@ -260,7 +260,7 @@ namespace Duplicati.CommandLine
if (lines.Count == 0)
foreach (Duplicati.Library.Interface.ICompression mod in Library.DynamicLoader.CompressionLoader.Modules)
- if (string.Equals(mod.FilenameExtension, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(mod.FilenameExtension, topic, StringComparison.OrdinalIgnoreCase))
{
PrintCompressionModule(mod, lines);
break;
@@ -268,7 +268,7 @@ namespace Duplicati.CommandLine
if (lines.Count == 0)
foreach (Duplicati.Library.Interface.IGenericModule mod in Library.DynamicLoader.GenericLoader.Modules)
- if (string.Equals(mod.Key, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(mod.Key, topic, StringComparison.OrdinalIgnoreCase))
{
PrintGenericModule(mod, lines);
break;
@@ -298,7 +298,7 @@ namespace Duplicati.CommandLine
foreach (Duplicati.Library.Interface.ICommandLineArgument arg in args)
{
- if (string.Equals(arg.Name, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(arg.Name, topic, StringComparison.OrdinalIgnoreCase))
{
Library.Interface.CommandLineArgument.PrintArgument(lines, arg, " ");
return;
@@ -307,7 +307,7 @@ namespace Duplicati.CommandLine
if (arg.Aliases != null)
foreach (string k in arg.Aliases)
{
- if (string.Equals(k, topic, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(k, topic, StringComparison.OrdinalIgnoreCase))
{
Library.Interface.CommandLineArgument.PrintArgument(lines, arg, " ");
return;
@@ -437,7 +437,7 @@ namespace Duplicati.CommandLine
private class Matcher
{
- Dictionary<string, Library.Interface.ICommandLineArgument> args = new Dictionary<string, Library.Interface.ICommandLineArgument>(StringComparer.InvariantCultureIgnoreCase);
+ Dictionary<string, Library.Interface.ICommandLineArgument> args = new Dictionary<string, Library.Interface.ICommandLineArgument>(StringComparer.OrdinalIgnoreCase);
public Matcher()
{
diff --git a/Duplicati/CommandLine/Program.cs b/Duplicati/CommandLine/Program.cs
index fa94e666a..2dd252148 100644
--- a/Duplicati/CommandLine/Program.cs
+++ b/Duplicati/CommandLine/Program.cs
@@ -72,7 +72,7 @@ namespace Duplicati.CommandLine
{
get
{
- var knownCommands = new Dictionary<string, Func<TextWriter, Action<Library.Main.Controller>, List<string>, Dictionary<string, string>, Library.Utility.IFilter, int>>(StringComparer.InvariantCultureIgnoreCase);
+ var knownCommands = new Dictionary<string, Func<TextWriter, Action<Library.Main.Controller>, List<string>, Dictionary<string, string>, Library.Utility.IFilter, int>>(StringComparer.OrdinalIgnoreCase);
knownCommands["help"] = Commands.Help;
knownCommands["example"] = Commands.Examples;
knownCommands["examples"] = Commands.Examples;
@@ -126,7 +126,7 @@ namespace Duplicati.CommandLine
verboseErrors = Library.Utility.Utility.ParseBoolOption(options, "debug-output");
verbose = Library.Utility.Utility.ParseBoolOption(options, "verbose");
- if (cargs.Count == 1 && string.Equals(cargs[0], "changelog", StringComparison.InvariantCultureIgnoreCase))
+ if (cargs.Count == 1 && string.Equals(cargs[0], "changelog", StringComparison.OrdinalIgnoreCase))
{
var path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "changelog.txt");
outwriter.WriteLine(System.IO.File.ReadAllText(path));
@@ -141,7 +141,7 @@ namespace Duplicati.CommandLine
}
// Probe for "help" to avoid extra processing
- bool isHelp = cargs.Count == 0 || (cargs.Count >= 1 && string.Equals(cargs[0], "help", StringComparison.InvariantCultureIgnoreCase));
+ bool isHelp = cargs.Count == 0 || (cargs.Count >= 1 && string.Equals(cargs[0], "help", StringComparison.OrdinalIgnoreCase));
if (!isHelp && ((options.ContainsKey("parameters-file") && !string.IsNullOrEmpty("parameters-file")) || (options.ContainsKey("parameter-file") && !string.IsNullOrEmpty("parameter-file")) || (options.ContainsKey("parameterfile") && !string.IsNullOrEmpty("parameterfile"))))
{
string filename;
@@ -175,7 +175,7 @@ namespace Duplicati.CommandLine
command = "help";
// Update probe for help
- isHelp = string.Equals(command, "help", StringComparison.InvariantCultureIgnoreCase);
+ isHelp = string.Equals(command, "help", StringComparison.OrdinalIgnoreCase);
// Skip the env read if the command is help, otherwise we may report weirdness
if (!isHelp)
@@ -375,7 +375,7 @@ namespace Duplicati.CommandLine
cargs[1] = newtarget;
}
- if (cargs.Count >= 1 && cargs[0].Equals("backup", StringComparison.InvariantCultureIgnoreCase))
+ if (cargs.Count >= 1 && cargs[0].Equals("backup", StringComparison.OrdinalIgnoreCase))
cargs.AddRange(newsource);
else if (newsource.Count > 0 && Library.Utility.Utility.ParseBoolOption(options, "verbose"))
outwriter.WriteLine(Strings.Program.SkippingSourceArgumentsOnNonBackupOperation);
diff --git a/Duplicati/CommandLine/RecoveryTool/Program.cs b/Duplicati/CommandLine/RecoveryTool/Program.cs
index 7170126d2..e37eda13e 100644
--- a/Duplicati/CommandLine/RecoveryTool/Program.cs
+++ b/Duplicati/CommandLine/RecoveryTool/Program.cs
@@ -52,7 +52,7 @@ namespace Duplicati.CommandLine.RecoveryTool
if (options.ContainsKey("tempdir") && !string.IsNullOrEmpty(options["tempdir"]))
Library.Utility.TempFolder.SetSystemTempPath(options["tempdir"]);
- bool isHelp = args.Count == 0 || (args.Count >= 1 && string.Equals(args[0], "help", StringComparison.InvariantCultureIgnoreCase));
+ bool isHelp = args.Count == 0 || (args.Count >= 1 && string.Equals(args[0], "help", StringComparison.OrdinalIgnoreCase));
if (!isHelp && ((options.ContainsKey("parameters-file") && !string.IsNullOrEmpty("parameters-file")) || (options.ContainsKey("parameter-file") && !string.IsNullOrEmpty("parameter-file")) || (options.ContainsKey("parameterfile") && !string.IsNullOrEmpty("parameterfile"))))
{
string filename;
@@ -76,7 +76,7 @@ namespace Duplicati.CommandLine.RecoveryTool
return 100;
}
- var actions = new Dictionary<string, CommandRunner>(StringComparer.InvariantCultureIgnoreCase);
+ var actions = new Dictionary<string, CommandRunner>(StringComparer.OrdinalIgnoreCase);
actions["download"] = Download.Run;
actions["recompress"] = Recompress.Run;
actions["index"] = Index.Run;
@@ -125,7 +125,7 @@ namespace Duplicati.CommandLine.RecoveryTool
cargs.AddRange(
from c in fargs
- where !string.IsNullOrWhiteSpace(c) && !c.StartsWith("#") && !c.StartsWith("!") && !c.StartsWith("REM ", StringComparison.InvariantCultureIgnoreCase)
+ where !string.IsNullOrWhiteSpace(c) && !c.StartsWith("#") && !c.StartsWith("!") && !c.StartsWith("REM ", StringComparison.OrdinalIgnoreCase)
select c
);
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HostedInstanceKeeper.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HostedInstanceKeeper.cs
index 8bd33f5c2..ab18b26c3 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HostedInstanceKeeper.cs
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HostedInstanceKeeper.cs
@@ -21,7 +21,7 @@ namespace Duplicati.GUI.TrayIcon
{
//When running the hosted instance we do not really care what port we are using,
// so we just throw a few out there and try them
- if (args == null || !args.Any(x => x.Trim().StartsWith("--" + Duplicati.Server.WebServer.Server.OPTION_PORT + "=", StringComparison.InvariantCultureIgnoreCase)))
+ if (args == null || !args.Any(x => x.Trim().StartsWith("--" + Duplicati.Server.WebServer.Server.OPTION_PORT + "=", StringComparison.OrdinalIgnoreCase)))
args = (args ?? new string[0]).Union(new string[] { "--" + Duplicati.Server.WebServer.Server.OPTION_PORT + "=8200,8300,8400,8500,8600,8700,8800,8900,8989" }).ToArray();
Duplicati.Server.Program.Main(args);
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs
index ad91d22d5..97c9ff33a 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/HttpServerConnection.cs
@@ -349,7 +349,7 @@ namespace Duplicati.GUI.TrayIcon
!hasTriedXSRF &&
wex.Status == System.Net.WebExceptionStatus.ProtocolError &&
httpex.StatusCode == System.Net.HttpStatusCode.BadRequest &&
- httpex.StatusDescription.IndexOf("XSRF", StringComparison.InvariantCultureIgnoreCase) >= 0)
+ httpex.StatusDescription.IndexOf("XSRF", StringComparison.OrdinalIgnoreCase) >= 0)
{
hasTriedXSRF = true;
var t = httpex.Cookies[XSRF_COOKIE]?.Value;
@@ -387,16 +387,16 @@ namespace Duplicati.GUI.TrayIcon
{
queryparams["format"] = "json";
- string query = EncodeQueryString(queryparams);
-
- // TODO: This can interfere with running backups,
+ string query = EncodeQueryString(queryparams);
+
+ // TODO: This can interfere with running backups,
// as the System.Net.ServicePointManager is shared with
- // all connections doing ftp/http requests
- using (var httpOptions = new Duplicati.Library.Modules.Builtin.HttpOptions())
- {
- httpOptions.Configure(m_options);
-
- var req =
+ // all connections doing ftp/http requests
+ using (var httpOptions = new Duplicati.Library.Modules.Builtin.HttpOptions())
+ {
+ httpOptions.Configure(m_options);
+
+ var req =
(System.Net.HttpWebRequest) System.Net.WebRequest.Create(
new Uri(m_apiUri + endpoint + '?' + query));
req.Method = method;
@@ -419,7 +419,7 @@ namespace Duplicati.GUI.TrayIcon
req.AllowWriteStreamBuffering = true;
//Assign the timeout, and add a little processing time as well
- if (endpoint.Equals("/serverstate", StringComparison.InvariantCultureIgnoreCase) &&
+ if (endpoint.Equals("/serverstate", StringComparison.OrdinalIgnoreCase) &&
queryparams.ContainsKey("duration"))
areq.Timeout = (int) (Duplicati.Library.Utility.Timeparser.ParseTimeSpan(queryparams["duration"]) +
TimeSpan.FromSeconds(5)).TotalMilliseconds;
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/ImageLoader.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/ImageLoader.cs
index 8f1dec438..be35ef172 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/ImageLoader.cs
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/ImageLoader.cs
@@ -56,7 +56,7 @@ namespace Duplicati.GUI.TrayIcon
if (ICONS.TryGetValue(cachename, out ico))
return ico;
- if (!filename.EndsWith(".ico", StringComparison.InvariantCultureIgnoreCase))
+ if (!filename.EndsWith(".ico", StringComparison.OrdinalIgnoreCase))
using(var ms = new System.IO.MemoryStream())
{
Icon ic;
diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs
index 997c7ac3b..bbd2912eb 100644
--- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs
+++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs
@@ -45,7 +45,7 @@ namespace Duplicati.GUI.TrayIcon
}
else
#endif
- {
+ {
//Windows users expect a WinForms element
return TOOLKIT_WINDOWS_FORMS;
}
@@ -71,10 +71,10 @@ namespace Duplicati.GUI.TrayIcon
foreach (string s in args)
if (
- s.Equals("help", StringComparison.InvariantCultureIgnoreCase) ||
- s.Equals("/help", StringComparison.InvariantCultureIgnoreCase) ||
- s.Equals("usage", StringComparison.InvariantCultureIgnoreCase) ||
- s.Equals("/usage", StringComparison.InvariantCultureIgnoreCase))
+ s.Equals("help", StringComparison.OrdinalIgnoreCase) ||
+ s.Equals("/help", StringComparison.OrdinalIgnoreCase) ||
+ s.Equals("usage", StringComparison.OrdinalIgnoreCase) ||
+ s.Equals("/usage", StringComparison.OrdinalIgnoreCase))
options["help"] = "";
if (options.ContainsKey("help"))
@@ -85,9 +85,9 @@ namespace Duplicati.GUI.TrayIcon
foreach (Library.Interface.ICommandLineArgument arg in SupportedCommands)
{
Console.WriteLine("--{0}: {1}", arg.Name, arg.LongDescription);
- if (arg.Name == TOOLKIT_OPTION)
+ if (arg.Name == TOOLKIT_OPTION)
Console.WriteLine(" Supported toolkits: {0}{1}", string.Join(", ", arg.ValidValues), Environment.NewLine);
- }
+ }
Console.WriteLine("Additionally, these server options are also supported:");
Console.WriteLine();
@@ -104,24 +104,24 @@ namespace Duplicati.GUI.TrayIcon
if (!options.TryGetValue(TOOLKIT_OPTION, out toolkit))
{
#if !(__MonoCS__ || __WindowsGTK__ || ENABLE_GTK)
- if (Library.Utility.Utility.IsClientLinux && !Library.Utility.Utility.IsClientOSX)
- Console.WriteLine("Warning: this build does not support GTK, rebuild with ENABLE_GTK defined");
+ if (Library.Utility.Utility.IsClientLinux && !Library.Utility.Utility.IsClientOSX)
+ Console.WriteLine("Warning: this build does not support GTK, rebuild with ENABLE_GTK defined");
#endif
- toolkit = GetDefaultToolKit(true);
+ toolkit = GetDefaultToolKit(true);
}
else
{
- if (TOOLKIT_WINDOWS_FORMS.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
+ if (TOOLKIT_WINDOWS_FORMS.Equals(toolkit, StringComparison.OrdinalIgnoreCase))
toolkit = TOOLKIT_WINDOWS_FORMS;
#if __MonoCS__ || __WindowsGTK__ || ENABLE_GTK
- else if (TOOLKIT_GTK.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
+ else if (TOOLKIT_GTK.Equals(toolkit, StringComparison.OrdinalIgnoreCase))
toolkit = TOOLKIT_GTK;
- else if (TOOLKIT_GTK_APP_INDICATOR.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
+ else if (TOOLKIT_GTK_APP_INDICATOR.Equals(toolkit, StringComparison.OrdinalIgnoreCase))
toolkit = TOOLKIT_GTK_APP_INDICATOR;
#endif
- else if (TOOLKIT_COCOA.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
+ else if (TOOLKIT_COCOA.Equals(toolkit, StringComparison.OrdinalIgnoreCase))
toolkit = TOOLKIT_COCOA;
- else if (TOOLKIT_RUMPS.Equals(toolkit, StringComparison.InvariantCultureIgnoreCase))
+ else if (TOOLKIT_RUMPS.Equals(toolkit, StringComparison.OrdinalIgnoreCase))
toolkit = TOOLKIT_RUMPS;
else
toolkit = GetDefaultToolKit(true);
@@ -274,7 +274,7 @@ namespace Duplicati.GUI.TrayIcon
else if (toolkit == TOOLKIT_GTK_APP_INDICATOR)
return GetAppIndicatorInstance();
#endif
- else if (toolkit == TOOLKIT_COCOA)
+ else if (toolkit == TOOLKIT_COCOA)
return GetCocoaRunnerInstance();
else if (toolkit == TOOLKIT_RUMPS)
return GetRumpsRunnerInstance();
@@ -297,7 +297,7 @@ namespace Duplicati.GUI.TrayIcon
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static TrayIconBase GetAppIndicatorInstance() { return new AppIndicatorRunner(); }
#endif
- [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
+ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static TrayIconBase GetCocoaRunnerInstance() { return new CocoaRunner(); }
private static TrayIconBase GetRumpsRunnerInstance() { return new RumpsRunner(); }
@@ -314,7 +314,7 @@ namespace Duplicati.GUI.TrayIcon
#if __MonoCS__ || __WindowsGTK__ || ENABLE_GTK
return typeof(Gtk.StatusIcon) != null && typeof(Gdk.Image) != null;
#else
- return false;
+ return false;
#endif
}
@@ -330,7 +330,7 @@ namespace Duplicati.GUI.TrayIcon
#if __MonoCS__ || __WindowsGTK__ || ENABLE_GTK
return typeof(AppIndicator.ApplicationIndicator) != null;
#else
- return false;
+ return false;
#endif
}
diff --git a/Duplicati/Library/AutoUpdater/AutoUpdateSettings.cs b/Duplicati/Library/AutoUpdater/AutoUpdateSettings.cs
index 850dab24b..43c3a48b3 100644
--- a/Duplicati/Library/AutoUpdater/AutoUpdateSettings.cs
+++ b/Duplicati/Library/AutoUpdater/AutoUpdateSettings.cs
@@ -145,9 +145,9 @@ namespace Duplicati.Library.AutoUpdater
// Update from older builds
- if (string.Equals(channelstring, "preview", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(channelstring, "preview", StringComparison.OrdinalIgnoreCase))
channelstring = ReleaseType.Experimental.ToString();
- if (string.Equals(channelstring, "rene", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(channelstring, "rene", StringComparison.OrdinalIgnoreCase))
channelstring = ReleaseType.Canary.ToString();
ReleaseType rt;
diff --git a/Duplicati/Library/AutoUpdater/UpdaterManager.cs b/Duplicati/Library/AutoUpdater/UpdaterManager.cs
index 112837dca..6328d461e 100644
--- a/Duplicati/Library/AutoUpdater/UpdaterManager.cs
+++ b/Duplicati/Library/AutoUpdater/UpdaterManager.cs
@@ -343,7 +343,7 @@ namespace Duplicati.Library.AutoUpdater
return null;
// Don't install a debug update on a release build and vice versa
- if (string.Equals(SelfVersion.ReleaseType, "Debug", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(update.ReleaseType, SelfVersion.ReleaseType, StringComparison.CurrentCultureIgnoreCase))
+ if (string.Equals(SelfVersion.ReleaseType, "Debug", StringComparison.OrdinalIgnoreCase) && !string.Equals(update.ReleaseType, SelfVersion.ReleaseType, StringComparison.CurrentCultureIgnoreCase))
return null;
ReleaseType rt;
@@ -479,7 +479,7 @@ namespace Duplicati.Library.AutoUpdater
{
foreach(var file in zip.ListFilesWithSize(""))
{
- if (System.IO.Path.IsPathRooted(file.Key) || file.Key.Trim().StartsWith("..", StringComparison.InvariantCultureIgnoreCase))
+ if (System.IO.Path.IsPathRooted(file.Key) || file.Key.Trim().StartsWith("..", StringComparison.OrdinalIgnoreCase))
throw new Exception(string.Format("Out-of-place file path detected: {0}", file.Key));
var targetpath = System.IO.Path.Combine(tempfolder, file.Key);
diff --git a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs
index 848c96a66..9cdcc09b9 100644
--- a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs
+++ b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs
@@ -226,7 +226,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
}
else if (filename.Contains("/"))
{
- remotePath += filename.Substring(0, filename.LastIndexOf("/", StringComparison.InvariantCulture));
+ remotePath += filename.Substring(0, filename.LastIndexOf("/", StringComparison.Ordinal));
}
// else: stripping the filename in this case ignoring it
}
@@ -583,7 +583,7 @@ namespace Duplicati.Library.Backend.AlternativeFTP
var certHash = (_validHashes != null && _validHashes.Length > 0) ? CoreUtility.ByteArrayAsHexString(e.Certificate.GetCertHash()) : null;
if (certHash != null)
{
- if (_validHashes.Any(hash => !string.IsNullOrEmpty(hash) && certHash.Equals(hash, StringComparison.InvariantCultureIgnoreCase)))
+ if (_validHashes.Any(hash => !string.IsNullOrEmpty(hash) && certHash.Equals(hash, StringComparison.OrdinalIgnoreCase)))
{
e.Accept = true;
}
diff --git a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs
index cbd93a80b..e24a949fa 100644
--- a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs
+++ b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs
@@ -354,9 +354,9 @@ namespace Duplicati.Library.Backend.AmazonCloudDrive
foreach(var n in lst.Data)
{
- if (string.Equals(CONTENT_KIND_FOLDER, n.Kind, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(CONTENT_KIND_FOLDER, n.Kind, StringComparison.OrdinalIgnoreCase))
res.Add(new FileEntry(n.Name) { IsFolder = true });
- else if (string.Equals(CONTENT_KIND_FILE, n.Kind, StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(CONTENT_KIND_FILE, n.Kind, StringComparison.OrdinalIgnoreCase))
{
cache[n.Name] = n.ID;
diff --git a/Duplicati/Library/Backend/Backblaze/B2.cs b/Duplicati/Library/Backend/Backblaze/B2.cs
index 047044e3e..82753f029 100644
--- a/Duplicati/Library/Backend/Backblaze/B2.cs
+++ b/Duplicati/Library/Backend/Backblaze/B2.cs
@@ -107,7 +107,7 @@ namespace Duplicati.Library.Backend.Backblaze
);
if (buckets != null && buckets.Buckets != null)
- m_bucket = buckets.Buckets.Where(x => string.Equals(x.BucketName, m_bucketname, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
+ m_bucket = buckets.Buckets.Where(x => string.Equals(x.BucketName, m_bucketname, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (m_bucket == null)
throw new FolderMissingException();
diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs
index 18a69bad5..dcdeb64db 100644
--- a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs
+++ b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs
@@ -148,7 +148,7 @@ namespace Duplicati.Library.Backend.GoogleCloudStorage
foreach(var f in resp.items)
{
var name = f.name;
- if (name.StartsWith(m_prefix, StringComparison.InvariantCultureIgnoreCase))
+ if (name.StartsWith(m_prefix, StringComparison.OrdinalIgnoreCase))
name = name.Substring(m_prefix.Length);
if (f.size == null)
res.Add(new FileEntry(name));
diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs
index 7adba4fae..c4e6af992 100644
--- a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs
+++ b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs
@@ -209,7 +209,7 @@ namespace Duplicati.Library.Backend.GoogleDrive
if (fe != null)
{
- fe.IsFolder = FOLDER_MIMETYPE.Equals(n.mimeType, StringComparison.InvariantCultureIgnoreCase);
+ fe.IsFolder = FOLDER_MIMETYPE.Equals(n.mimeType, StringComparison.OrdinalIgnoreCase);
res.Add(fe);
if (!fe.IsFolder)
diff --git a/Duplicati/Library/Backend/OneDrive/OneDrive.cs b/Duplicati/Library/Backend/OneDrive/OneDrive.cs
index f160daf62..289dd024a 100644
--- a/Duplicati/Library/Backend/OneDrive/OneDrive.cs
+++ b/Duplicati/Library/Backend/OneDrive/OneDrive.cs
@@ -30,7 +30,7 @@ namespace Duplicati.Library.Backend
private OAuthHelper m_oauth;
- private Dictionary<string, string> m_fileidCache = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
+ private Dictionary<string, string> m_fileidCache = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
private readonly byte[] m_copybuffer = new byte[Duplicati.Library.Utility.Utility.DEFAULT_BUFFER_SIZE];
@@ -118,7 +118,7 @@ namespace Duplicati.Library.Backend
return null;
foreach(var r in res.data)
- if (string.Equals(r.name, folder, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(r.name, folder, StringComparison.OrdinalIgnoreCase))
return r;
return null;
@@ -258,7 +258,7 @@ namespace Duplicati.Library.Backend
m_fileidCache.Add(r.name, r.id);
var fe = new FileEntry(r.name, r.size, r.updated_time, r.updated_time);
- fe.IsFolder = string.Equals(r.type, "folder", StringComparison.InvariantCultureIgnoreCase);
+ fe.IsFolder = string.Equals(r.type, "folder", StringComparison.OrdinalIgnoreCase);
files.Add(fe);
}
}
@@ -397,7 +397,7 @@ namespace Duplicati.Library.Backend
using(var resp = (HttpWebResponse)areq.GetResponse())
{
var packtype = resp.Headers["BITS-Packet-Type"];
- if (!packtype.Equals("Ack", StringComparison.InvariantCultureIgnoreCase))
+ if (!packtype.Equals("Ack", StringComparison.OrdinalIgnoreCase))
throw new Exception(string.Format("Unable to create BITS transfer, got status: {0}", packtype));
sessionid = resp.Headers["BITS-Session-Id"];
diff --git a/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs b/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs
index 2783c283e..91b68f1cc 100644
--- a/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs
+++ b/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs
@@ -255,7 +255,7 @@ namespace Duplicati.Library.Backend.OpenStack
m_accessToken = resp.access.token;
// Grab the endpoint now that we have received it anyway
- var fileservice = resp.access.serviceCatalog.Where(x => string.Equals(x.type, "object-store", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
+ var fileservice = resp.access.serviceCatalog.Where(x => string.Equals(x.type, "object-store", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (fileservice == null)
throw new Exception("No object-store service found, is this service supported by the provider?");
diff --git a/Duplicati/Library/Backend/S3/S3Backend.cs b/Duplicati/Library/Backend/S3/S3Backend.cs
index 46d1cb0ed..861a6dd69 100644
--- a/Duplicati/Library/Backend/S3/S3Backend.cs
+++ b/Duplicati/Library/Backend/S3/S3Backend.cs
@@ -200,7 +200,7 @@ namespace Duplicati.Library.Backend
//Change in S3, now requires that you use location specific endpoint
if (!string.IsNullOrEmpty(locationConstraint))
foreach(KeyValuePair<string, string> kvp in DEFAULT_S3_LOCATION_BASED_HOSTS)
- if (kvp.Key.Equals(locationConstraint, StringComparison.InvariantCultureIgnoreCase))
+ if (kvp.Key.Equals(locationConstraint, StringComparison.OrdinalIgnoreCase))
{
s3host = kvp.Value;
break;
@@ -258,12 +258,12 @@ namespace Duplicati.Library.Backend
if (m_prefix.Length != 0 && !m_prefix.EndsWith("/"))
m_prefix += "/";
- // Auto-disable dns lookup for non AWS configurations
+ // Auto-disable dns lookup for non AWS configurations
var hasForcePathStyle = options.ContainsKey("s3-ext-forcepathstyle");
if (!hasForcePathStyle && !DEFAULT_S3_LOCATION_BASED_HOSTS.Any(x => string.Equals(x.Value, host, StringComparison.OrdinalIgnoreCase)) && !string.Equals(host, "s3.amazonaws.com", StringComparison.OrdinalIgnoreCase))
options["s3-ext-forcepathstyle"] = "true";
-
- m_wrapper = new S3Wrapper(awsID, awsKey, locationConstraint, host, storageClass, useSSL, options);
+
+ m_wrapper = new S3Wrapper(awsID, awsKey, locationConstraint, host, storageClass, useSSL, options);
}
public static bool IsValidHostname(string bucketname)
diff --git a/Duplicati/Library/Backend/S3/S3Wrapper.cs b/Duplicati/Library/Backend/S3/S3Wrapper.cs
index 52d88352f..cbf1f543b 100644
--- a/Duplicati/Library/Backend/S3/S3Wrapper.cs
+++ b/Duplicati/Library/Backend/S3/S3Wrapper.cs
@@ -47,9 +47,9 @@ namespace Duplicati.Library.Backend
//cfg.UserAgent = "Duplicati v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " S3 client with AWS SDK v" + cfg.GetType().Assembly.GetName().Version.ToString();
cfg.BufferSize = (int)Duplicati.Library.Utility.Utility.DEFAULT_BUFFER_SIZE;
- foreach(var opt in options.Keys.Where(x => x.StartsWith("s3-ext-", StringComparison.InvariantCultureIgnoreCase)))
+ foreach(var opt in options.Keys.Where(x => x.StartsWith("s3-ext-", StringComparison.OrdinalIgnoreCase)))
{
- var prop = cfg.GetType().GetProperties().Where(x => string.Equals(x.Name, opt.Substring("s3-ext-".Length), StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
+ var prop = cfg.GetType().GetProperties().Where(x => string.Equals(x.Name, opt.Substring("s3-ext-".Length), StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (prop != null && prop.CanWrite)
{
if (prop.PropertyType == typeof(bool))
diff --git a/Duplicati/Library/Backend/SSHv2/KeyGenerator.cs b/Duplicati/Library/Backend/SSHv2/KeyGenerator.cs
index 52d5f9731..bc0e1140f 100644
--- a/Duplicati/Library/Backend/SSHv2/KeyGenerator.cs
+++ b/Duplicati/Library/Backend/SSHv2/KeyGenerator.cs
@@ -161,7 +161,7 @@ namespace Duplicati.Library.Backend
if (!int.TryParse(keylen_s, out keylen))
keylen = DEFAULT_KEYLEN;
- if (KEYTYPE_RSA.Equals(keytype, StringComparison.InvariantCultureIgnoreCase))
+ if (KEYTYPE_RSA.Equals(keytype, StringComparison.OrdinalIgnoreCase))
{
var rsa = RSACryptoServiceProvider.Create();
if (keylen > 0)
@@ -180,7 +180,7 @@ namespace Duplicati.Library.Backend
return OutputKey(EncodeDER(privateEntries), EncodePEM(publicEntries), KEY_TEMPLATE_RSA, PUB_KEY_FORMAT_RSA, username);
}
- else if (KEYTYPE_DSA.Equals(keytype, StringComparison.InvariantCultureIgnoreCase))
+ else if (KEYTYPE_DSA.Equals(keytype, StringComparison.OrdinalIgnoreCase))
{
var dsa = DSACryptoServiceProvider.Create();
diff --git a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
index e6c0db9e7..d32958872 100644
--- a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
+++ b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs
@@ -34,10 +34,10 @@ namespace Duplicati.Library.Backend
public const string SSH_FINGERPRINT_OPTION = "ssh-fingerprint";
public const string SSH_FINGERPRINT_ACCEPT_ANY_OPTION = "ssh-accept-any-fingerprints";
public const string KEYFILE_URI = "sshkey://";
- public const string SSH_TIMEOUT_OPTION = "ssh-operation-timeout";
- public const string SSH_KEEPALIVE_OPTION = "ssh-keepalive";
-
- Dictionary<string, string> m_options;
+ public const string SSH_TIMEOUT_OPTION = "ssh-operation-timeout";
+ public const string SSH_KEEPALIVE_OPTION = "ssh-keepalive";
+
+ Dictionary<string, string> m_options;
private string m_server;
private string m_path;
@@ -45,10 +45,10 @@ namespace Duplicati.Library.Backend
private string m_password;
private string m_fingerprint;
private bool m_fingerprintallowall;
- private TimeSpan m_operationtimeout;
- private TimeSpan m_keepaliveinterval;
-
- private int m_port = 22;
+ private TimeSpan m_operationtimeout;
+ private TimeSpan m_keepaliveinterval;
+
+ private int m_port = 22;
private SftpClient m_con;
@@ -93,14 +93,14 @@ namespace Duplicati.Library.Backend
options.TryGetValue(SSH_TIMEOUT_OPTION, out timeoutstr);
if (!string.IsNullOrWhiteSpace(timeoutstr))
- m_operationtimeout = Library.Utility.Timeparser.ParseTimeSpan(timeoutstr);
-
- options.TryGetValue(SSH_KEEPALIVE_OPTION, out timeoutstr);
-
- if (!string.IsNullOrWhiteSpace(timeoutstr))
- m_keepaliveinterval = Library.Utility.Timeparser.ParseTimeSpan(timeoutstr);
-
- }
+ m_operationtimeout = Library.Utility.Timeparser.ParseTimeSpan(timeoutstr);
+
+ options.TryGetValue(SSH_KEEPALIVE_OPTION, out timeoutstr);
+
+ if (!string.IsNullOrWhiteSpace(timeoutstr))
+ m_keepaliveinterval = Library.Utility.Timeparser.ParseTimeSpan(timeoutstr);
+
+ }
#region IBackend Members
@@ -166,10 +166,10 @@ namespace Duplicati.Library.Backend
new CommandLineArgument(SSH_FINGERPRINT_OPTION, CommandLineArgument.ArgumentType.String, Strings.SSHv2Backend.DescriptionFingerprintShort, Strings.SSHv2Backend.DescriptionFingerprintLong),
new CommandLineArgument(SSH_FINGERPRINT_ACCEPT_ANY_OPTION, CommandLineArgument.ArgumentType.Boolean, Strings.SSHv2Backend.DescriptionAnyFingerprintShort, Strings.SSHv2Backend.DescriptionAnyFingerprintLong),
new CommandLineArgument(SSH_KEYFILE_OPTION, CommandLineArgument.ArgumentType.Path, Strings.SSHv2Backend.DescriptionSshkeyfileShort, Strings.SSHv2Backend.DescriptionSshkeyfileLong),
- new CommandLineArgument(SSH_KEYFILE_INLINE, CommandLineArgument.ArgumentType.Password, Strings.SSHv2Backend.DescriptionSshkeyShort, Strings.SSHv2Backend.DescriptionSshkeyLong(KEYFILE_URI)),
- new CommandLineArgument(SSH_TIMEOUT_OPTION, CommandLineArgument.ArgumentType.Timespan, Strings.SSHv2Backend.DescriptionSshtimeoutShort, Strings.SSHv2Backend.DescriptionSshtimeoutLong, "0"),
+ new CommandLineArgument(SSH_KEYFILE_INLINE, CommandLineArgument.ArgumentType.Password, Strings.SSHv2Backend.DescriptionSshkeyShort, Strings.SSHv2Backend.DescriptionSshkeyLong(KEYFILE_URI)),
+ new CommandLineArgument(SSH_TIMEOUT_OPTION, CommandLineArgument.ArgumentType.Timespan, Strings.SSHv2Backend.DescriptionSshtimeoutShort, Strings.SSHv2Backend.DescriptionSshtimeoutLong, "0"),
new CommandLineArgument(SSH_KEEPALIVE_OPTION, CommandLineArgument.ArgumentType.Timespan, Strings.SSHv2Backend.DescriptionSshkeepaliveShort, Strings.SSHv2Backend.DescriptionSshkeepaliveLong, "0"),
- });
+ });
}
}
@@ -281,9 +281,9 @@ namespace Duplicati.Library.Backend
};
if (m_operationtimeout.Ticks != 0)
- con.OperationTimeout = m_operationtimeout;
- if (m_keepaliveinterval.Ticks != 0)
- con.KeepAliveInterval = m_keepaliveinterval;
+ con.OperationTimeout = m_operationtimeout;
+ if (m_keepaliveinterval.Ticks != 0)
+ con.KeepAliveInterval = m_keepaliveinterval;
con.Connect();
@@ -331,7 +331,7 @@ namespace Duplicati.Library.Backend
public static Renci.SshNet.PrivateKeyFile ValidateKeyFile(string filename, string password)
{
- if (filename.StartsWith(KEYFILE_URI, StringComparison.InvariantCultureIgnoreCase))
+ if (filename.StartsWith(KEYFILE_URI, StringComparison.OrdinalIgnoreCase))
{
using (var ms = new System.IO.MemoryStream())
using (var sr = new System.IO.StreamWriter(ms))
diff --git a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs
index 962aae9b4..4793cf9a1 100644
--- a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs
+++ b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs
@@ -303,7 +303,7 @@ namespace Duplicati.Library.Backend
// Now go through path and see where we land a success.
string[] pathParts = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
// first we look for the doc library
- int docLibrary = Array.FindIndex(pathParts, p => StringComparer.InvariantCultureIgnoreCase.Equals(p, "documents"));
+ int docLibrary = Array.FindIndex(pathParts, p => StringComparer.OrdinalIgnoreCase.Equals(p, "documents"));
if (docLibrary >= 0)
{
string testUrl = new Utility.Uri(orgUrl.Scheme, orgUrl.Host,
diff --git a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs
index b11a84fa1..6662755f8 100644
--- a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs
+++ b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs
@@ -242,8 +242,8 @@ namespace Duplicati.Library.Backend
throw new Interface.FolderMissingException(Strings.WEBDAV.MissingFolderError(m_path, wex.Message), wex);
if (wex.Response as System.Net.HttpWebResponse != null && (wex.Response as System.Net.HttpWebResponse).StatusCode == System.Net.HttpStatusCode.MethodNotAllowed)
- throw new UserInformationException(Strings.WEBDAV.MethodNotAllowedError((wex.Response as System.Net.HttpWebResponse).StatusCode), wex);
-
+ throw new UserInformationException(Strings.WEBDAV.MethodNotAllowedError((wex.Response as System.Net.HttpWebResponse).StatusCode), wex);
+
throw;
}
}
diff --git a/Duplicati/Library/DynamicLoader/BackendLoader.cs b/Duplicati/Library/DynamicLoader/BackendLoader.cs
index 6d48516d5..fab99a87d 100644
--- a/Duplicati/Library/DynamicLoader/BackendLoader.cs
+++ b/Duplicati/Library/DynamicLoader/BackendLoader.cs
@@ -84,8 +84,8 @@ namespace Duplicati.Library.DynamicLoader
{
var commands = m_interfaces[tmpscheme].SupportedCommands;
if (commands != null && (commands.Where(x =>
- x.Name.Equals("use-ssl", StringComparison.InvariantCultureIgnoreCase) ||
- (x.Aliases != null && x.Aliases.Where(y => y.Equals("use-ssl", StringComparison.InvariantCultureIgnoreCase)).Any())
+ x.Name.Equals("use-ssl", StringComparison.OrdinalIgnoreCase) ||
+ (x.Aliases != null && x.Aliases.Where(y => y.Equals("use-ssl", StringComparison.OrdinalIgnoreCase)).Any())
).Any()))
{
newOpts["use-ssl"] = "true";
diff --git a/Duplicati/Library/Localization/MoLocalizationService.cs b/Duplicati/Library/Localization/MoLocalizationService.cs
index ff3f4b8e1..2b94d6f1c 100644
--- a/Duplicati/Library/Localization/MoLocalizationService.cs
+++ b/Duplicati/Library/Localization/MoLocalizationService.cs
@@ -92,7 +92,7 @@ namespace Duplicati.Library.Localization
var names =
from name in SearchAssembly.GetManifestResourceNames()
let m = CI_MATCHER.Match(name)
- let c = m.Success && string.Equals(m.Value, fn, StringComparison.InvariantCultureIgnoreCase) ? LocalizationService.ParseCulture(m.Groups["culture"].Value) : null
+ let c = m.Success && string.Equals(m.Value, fn, StringComparison.OrdinalIgnoreCase) ? LocalizationService.ParseCulture(m.Groups["culture"].Value) : null
where c != null
select name;
diff --git a/Duplicati/Library/Main/BackendManager.cs b/Duplicati/Library/Main/BackendManager.cs
index 2cab8a76e..d9d22e11c 100644
--- a/Duplicati/Library/Main/BackendManager.cs
+++ b/Duplicati/Library/Main/BackendManager.cs
@@ -700,10 +700,10 @@ namespace Duplicati.Library.Main
}
}
- private string m_lastThrottleUploadValue = null;
- private string m_lastThrottleDownloadValue = null;
-
- private void HandleProgress(ThrottledStream ts, long pg)
+ private string m_lastThrottleUploadValue = null;
+ private string m_lastThrottleDownloadValue = null;
+
+ private void HandleProgress(ThrottledStream ts, long pg)
{
// TODO: Should we pause here as well?
// It might give annoying timeouts for transfers
@@ -717,10 +717,10 @@ namespace Duplicati.Library.Main
{
ts.WriteSpeed = m_options.MaxUploadPrSecond;
m_lastThrottleUploadValue = tmp;
- }
-
- m_options.RawOptions.TryGetValue("throttle-download", out tmp);
- if (tmp != m_lastThrottleDownloadValue)
+ }
+
+ m_options.RawOptions.TryGetValue("throttle-download", out tmp);
+ if (tmp != m_lastThrottleDownloadValue)
{
ts.ReadSpeed = m_options.MaxDownloadPrSecond;
m_lastThrottleDownloadValue = tmp;
@@ -753,8 +753,8 @@ namespace Duplicati.Library.Main
if (m_backend is Library.Interface.IStreamingBackend && !m_options.DisableStreamingTransfers)
{
using (var fs = System.IO.File.OpenRead(item.LocalFilename))
- using (var ts = new ThrottledStream(fs, m_options.MaxUploadPrSecond, m_options.MaxDownloadPrSecond))
- using (var pgs = new Library.Utility.ProgressReportingStream(ts, item.Size, pg => HandleProgress(ts, pg)))
+ using (var ts = new ThrottledStream(fs, m_options.MaxUploadPrSecond, m_options.MaxDownloadPrSecond))
+ using (var pgs = new Library.Utility.ProgressReportingStream(ts, item.Size, pg => HandleProgress(ts, pg)))
((Library.Interface.IStreamingBackend)m_backend).Put(item.RemoteFilename, pgs);
}
else
@@ -770,7 +770,7 @@ namespace Duplicati.Library.Main
if (m_options.ListVerifyUploads)
{
- var f = m_backend.List().Where(n => n.Name.Equals(item.RemoteFilename, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
+ var f = m_backend.List().Where(n => n.Name.Equals(item.RemoteFilename, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (f == null)
throw new Exception(string.Format("List verify failed, file was not found after upload: {0}", item.RemoteFilename));
else if (f.Size != item.Size && f.Size >= 0)
@@ -932,8 +932,8 @@ namespace Duplicati.Library.Main
using (var hs = GetFileHasherStream(fs, System.Security.Cryptography.CryptoStreamMode.Write, out getFileHash))
using (var ss = new ShaderStream(hs, true))
{
- using (var ts = new ThrottledStream(ss, m_options.MaxUploadPrSecond, m_options.MaxDownloadPrSecond))
- using (var pgs = new Library.Utility.ProgressReportingStream(ts, item.Size, pg => HandleProgress(ts, pg)))
+ using (var ts = new ThrottledStream(ss, m_options.MaxUploadPrSecond, m_options.MaxDownloadPrSecond))
+ using (var pgs = new Library.Utility.ProgressReportingStream(ts, item.Size, pg => HandleProgress(ts, pg)))
{ ((Library.Interface.IStreamingBackend)m_backend).Get(item.RemoteFilename, pgs); }
ss.Flush();
retDownloadSize = ss.TotalBytesWritten;
@@ -1000,17 +1000,17 @@ namespace Duplicati.Library.Main
{
// Auto-guess the encryption module
var ext = (System.IO.Path.GetExtension(item.RemoteFilename) ?? "").TrimStart('.');
- if (!m_encryption.FilenameExtension.Equals(ext, StringComparison.InvariantCultureIgnoreCase))
+ if (!m_encryption.FilenameExtension.Equals(ext, StringComparison.OrdinalIgnoreCase))
{
// Check if the file is encrypted with something else
- if (DynamicLoader.EncryptionLoader.Keys.Contains(ext, StringComparer.InvariantCultureIgnoreCase))
+ if (DynamicLoader.EncryptionLoader.Keys.Contains(ext, StringComparer.OrdinalIgnoreCase))
{
m_statwriter.AddVerboseMessage("Filename extension \"{0}\" does not match encryption module \"{1}\", using matching encryption module", ext, m_options.EncryptionModule);
useDecrypter = DynamicLoader.EncryptionLoader.GetModule(ext, m_options.Passphrase, m_options.RawOptions);
useDecrypter = useDecrypter ?? m_encryption;
}
// Check if the file is not encrypted
- else if (DynamicLoader.CompressionLoader.Keys.Contains(ext, StringComparer.InvariantCultureIgnoreCase))
+ else if (DynamicLoader.CompressionLoader.Keys.Contains(ext, StringComparer.OrdinalIgnoreCase))
{
m_statwriter.AddVerboseMessage("Filename extension \"{0}\" does not match encryption module \"{1}\", guessing that it is not encrypted", ext, m_options.EncryptionModule);
useDecrypter = null;
@@ -1302,9 +1302,9 @@ namespace Duplicati.Library.Main
finally
{
m_statwriter.BackendProgressUpdater.SetBlocking(false);
- }
-
- if (m_lastException != null)
+ }
+
+ if (m_lastException != null)
throw m_lastException;
return (Library.Utility.TempFile)req.Result;
@@ -1321,13 +1321,13 @@ namespace Duplicati.Library.Main
m_statwriter.BackendProgressUpdater.SetBlocking(true);
if (m_queue.Enqueue(req))
return req;
- }
- finally
- {
- m_statwriter.BackendProgressUpdater.SetBlocking(false);
- }
-
- if (m_lastException != null)
+ }
+ finally
+ {
+ m_statwriter.BackendProgressUpdater.SetBlocking(false);
+ }
+
+ if (m_lastException != null)
throw m_lastException;
else
throw new InvalidOperationException("GetAsync called after backend is shut down");
diff --git a/Duplicati/Library/Main/Controller.cs b/Duplicati/Library/Main/Controller.cs
index 787e43047..0b920fd8e 100644
--- a/Duplicati/Library/Main/Controller.cs
+++ b/Duplicati/Library/Main/Controller.cs
@@ -220,7 +220,7 @@ namespace Duplicati.Library.Main
expandedSources.Add(expandedSource);
}
}
- else if (Library.Utility.Utility.IsClientWindows && inputsources[i].StartsWith(@"\\?\Volume{", StringComparison.InvariantCultureIgnoreCase))
+ else if (Library.Utility.Utility.IsClientWindows && inputsources[i].StartsWith(@"\\?\Volume{", StringComparison.OrdinalIgnoreCase))
{
// In order to specify a drive by it's volume name, adopt the volume guid path syntax:
// \\?\Volume{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
diff --git a/Duplicati/Library/Main/DatabaseLocator.cs b/Duplicati/Library/Main/DatabaseLocator.cs
index 336ca51bc..c2d54616f 100644
--- a/Duplicati/Library/Main/DatabaseLocator.cs
+++ b/Duplicati/Library/Main/DatabaseLocator.cs
@@ -43,33 +43,33 @@ namespace Duplicati.Library.Main
options = new Options(new Dictionary<string, string>());
if (!string.IsNullOrEmpty(options.Dbpath))
- return options.Dbpath;
-
- //Normal mode uses the systems "(Local) Application Data" folder
- // %LOCALAPPDATA% on Windows, ~/.config on Linux
-
- // Special handling for Windows:
- // - Older versions use %APPDATA%
- // - but new versions use %LOCALAPPDATA%
- //
- // If we find a new version, lets use that
- // otherwise use the older location
- //
-
- var folder = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Duplicati");
-
- if (Duplicati.Library.Utility.Utility.IsClientWindows)
- {
- var newlocation = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Duplicati");
-
- var prevfile = System.IO.Path.Combine(folder, "dbconfig.json");
- var curfile = System.IO.Path.Combine(newlocation, "dbconfig.json");
-
- // If the new file exists, we use that
- // If the new file does not exist, and the old file exists we use the old
- // Otherwise we use the new location
- if (System.IO.File.Exists(curfile) || !System.IO.File.Exists(prevfile))
- folder = newlocation;
+ return options.Dbpath;
+
+ //Normal mode uses the systems "(Local) Application Data" folder
+ // %LOCALAPPDATA% on Windows, ~/.config on Linux
+
+ // Special handling for Windows:
+ // - Older versions use %APPDATA%
+ // - but new versions use %LOCALAPPDATA%
+ //
+ // If we find a new version, lets use that
+ // otherwise use the older location
+ //
+
+ var folder = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Duplicati");
+
+ if (Duplicati.Library.Utility.Utility.IsClientWindows)
+ {
+ var newlocation = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Duplicati");
+
+ var prevfile = System.IO.Path.Combine(folder, "dbconfig.json");
+ var curfile = System.IO.Path.Combine(newlocation, "dbconfig.json");
+
+ // If the new file exists, we use that
+ // If the new file does not exist, and the old file exists we use the old
+ // Otherwise we use the new location
+ if (System.IO.File.Exists(curfile) || !System.IO.File.Exists(prevfile))
+ folder = newlocation;
}
if (!System.IO.Directory.Exists(folder))
@@ -102,17 +102,17 @@ namespace Duplicati.Library.Main
{
foreach(var o in sopts)
{
- if (username == null && o.Aliases != null && o.Aliases.Contains("auth-username", StringComparer.InvariantCultureIgnoreCase) && ropts.ContainsKey(o.Name))
+ if (username == null && o.Aliases != null && o.Aliases.Contains("auth-username", StringComparer.OrdinalIgnoreCase) && ropts.ContainsKey(o.Name))
username = ropts[o.Name];
- if (password == null && o.Aliases != null && o.Aliases.Contains("auth-password", StringComparer.InvariantCultureIgnoreCase) && ropts.ContainsKey(o.Name))
+ if (password == null && o.Aliases != null && o.Aliases.Contains("auth-password", StringComparer.OrdinalIgnoreCase) && ropts.ContainsKey(o.Name))
password = ropts[o.Name];
}
foreach(var o in sopts)
{
- if (username == null && o.Name.Equals("auth-username", StringComparison.InvariantCultureIgnoreCase) && ropts.ContainsKey("auth-username"))
+ if (username == null && o.Name.Equals("auth-username", StringComparison.OrdinalIgnoreCase) && ropts.ContainsKey("auth-username"))
username = ropts["auth-username"];
- if (password == null && o.Name.Equals("auth-password", StringComparison.InvariantCultureIgnoreCase) && ropts.ContainsKey("auth-password"))
+ if (password == null && o.Name.Equals("auth-password", StringComparison.OrdinalIgnoreCase) && ropts.ContainsKey("auth-password"))
password = ropts["auth-password"];
}
}
diff --git a/Duplicati/Library/Main/Options.cs b/Duplicati/Library/Main/Options.cs
index e82403930..c21f0bab4 100644
--- a/Duplicati/Library/Main/Options.cs
+++ b/Duplicati/Library/Main/Options.cs
@@ -481,8 +481,8 @@ namespace Duplicati.Library.Main
new CommandLineArgument("restore-permissions", CommandLineArgument.ArgumentType.Boolean, Strings.Options.RestorepermissionsShort, Strings.Options.RestorepermissionsLong, "false"),
new CommandLineArgument("skip-restore-verification", CommandLineArgument.ArgumentType.Boolean, Strings.Options.SkiprestoreverificationShort, Strings.Options.SkiprestoreverificationLong, "false"),
new CommandLineArgument("disable-filepath-cache", CommandLineArgument.ArgumentType.Boolean, Strings.Options.DisablefilepathcacheShort, Strings.Options.DisablefilepathcacheLong, "true"),
- new CommandLineArgument("use-block-cache", CommandLineArgument.ArgumentType.Boolean, Strings.Options.UseblockcacheShort, Strings.Options.UseblockcacheLong, "false"),
- new CommandLineArgument("changed-files", CommandLineArgument.ArgumentType.Path, Strings.Options.ChangedfilesShort, Strings.Options.ChangedfilesLong),
+ new CommandLineArgument("use-block-cache", CommandLineArgument.ArgumentType.Boolean, Strings.Options.UseblockcacheShort, Strings.Options.UseblockcacheLong, "false"),
+ new CommandLineArgument("changed-files", CommandLineArgument.ArgumentType.Path, Strings.Options.ChangedfilesShort, Strings.Options.ChangedfilesLong),
new CommandLineArgument("deleted-files", CommandLineArgument.ArgumentType.Path, Strings.Options.DeletedfilesShort, Strings.Options.DeletedfilesLong("changed-files")),
new CommandLineArgument("disable-synthetic-filelist", CommandLineArgument.ArgumentType.Boolean, Strings.Options.DisablesyntheticfilelistShort, Strings.Options.DisablesyntehticfilelistLong, "false"),
@@ -1083,13 +1083,13 @@ namespace Duplicati.Library.Main
if (!m_options.TryGetValue("snapshot-policy", out strategy))
strategy = "";
- if (string.Equals(strategy, "on", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(strategy, "on", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.On;
- else if (string.Equals(strategy, "off", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(strategy, "off", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.Off;
- else if (string.Equals(strategy, "required", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(strategy, "required", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.Required;
- else if (string.Equals(strategy, "auto", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(strategy, "auto", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.Auto;
else
return OptimizationStrategy.Off;
@@ -1144,13 +1144,13 @@ namespace Duplicati.Library.Main
if (!m_options.TryGetValue("usn-policy", out strategy))
strategy = "";
- if (string.Equals(strategy, "on", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(strategy, "on", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.On;
- else if (string.Equals(strategy, "off", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(strategy, "off", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.Off;
- else if (string.Equals(strategy, "required", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(strategy, "required", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.Required;
- else if (string.Equals(strategy, "auto", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(strategy, "auto", StringComparison.OrdinalIgnoreCase))
return OptimizationStrategy.Auto;
else
return OptimizationStrategy.Off;
@@ -1220,7 +1220,7 @@ namespace Duplicati.Library.Main
value = null;
foreach (string s in Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType)))
- if (s.Equals(value, StringComparison.InvariantCultureIgnoreCase))
+ if (s.Equals(value, StringComparison.OrdinalIgnoreCase))
return true;
return false;
@@ -1239,7 +1239,7 @@ namespace Duplicati.Library.Main
value = null;
foreach (string s in Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType)))
- if (s.Equals(value, StringComparison.InvariantCultureIgnoreCase))
+ if (s.Equals(value, StringComparison.OrdinalIgnoreCase))
return (Duplicati.Library.Logging.LogMessageType)Enum.Parse(typeof(Duplicati.Library.Logging.LogMessageType), s);
return Duplicati.Library.Logging.LogMessageType.Warning;
@@ -1463,7 +1463,7 @@ namespace Duplicati.Library.Main
get
{
return Library.Utility.Utility.ParseBoolOption(m_options, "use-block-cache");
- }
+ }
}
diff --git a/Duplicati/Library/Main/Volumes/VolumeBase.cs b/Duplicati/Library/Main/Volumes/VolumeBase.cs
index a4091dc80..c0af0a228 100644
--- a/Duplicati/Library/Main/Volumes/VolumeBase.cs
+++ b/Duplicati/Library/Main/Volumes/VolumeBase.cs
@@ -73,7 +73,7 @@ namespace Duplicati.Library.Main.Volumes
dict[RemoteVolumeType.Files] = "dlist";
dict[RemoteVolumeType.Index] = "dindex";
- var reversedict = new Dictionary<string, RemoteVolumeType>(System.StringComparer.InvariantCultureIgnoreCase);
+ var reversedict = new Dictionary<string, RemoteVolumeType>(System.StringComparer.OrdinalIgnoreCase);
foreach(var x in dict)
reversedict[x.Value] = x.Key;
diff --git a/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs b/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs
index 95b6ea765..7b7bb9302 100644
--- a/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs
+++ b/Duplicati/Library/Modules/Builtin/ConsolePasswordInput.cs
@@ -47,14 +47,14 @@ namespace Duplicati.Library.Modules.Builtin
//First see if a password is actually required for the action
foreach (string s in PASSPHRASELESS_ACTIONS)
- if (string.Equals(s, commandlineOptions["main-action"], StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(s, commandlineOptions["main-action"], StringComparison.OrdinalIgnoreCase))
return;
//See if a password is already present or encryption is disabled
if (!commandlineOptions.ContainsKey("passphrase") && !Duplicati.Library.Utility.Utility.ParseBoolOption(commandlineOptions, "no-encryption"))
{
//Get the passphrase
- bool confirm = string.Equals(commandlineOptions["main-action"], "backup", StringComparison.InvariantCultureIgnoreCase);
+ bool confirm = string.Equals(commandlineOptions["main-action"], "backup", StringComparison.OrdinalIgnoreCase);
commandlineOptions["passphrase"] = ReadPassphraseFromConsole(confirm);
}
}
diff --git a/Duplicati/Library/Modules/Builtin/RunScript.cs b/Duplicati/Library/Modules/Builtin/RunScript.cs
index cad5b688e..6f9f69cf6 100644
--- a/Duplicati/Library/Modules/Builtin/RunScript.cs
+++ b/Duplicati/Library/Modules/Builtin/RunScript.cs
@@ -21,8 +21,8 @@ using System.IO;
using System.Text;
using System.Collections.Generic;
using Duplicati.Library.Utility;
-using Duplicati.Library.Interface;
-
+using Duplicati.Library.Interface;
+
namespace Duplicati.Library.Modules.Builtin
{
public class RunScript : Duplicati.Library.Interface.IGenericCallbackModule
@@ -97,16 +97,16 @@ namespace Duplicati.Library.Modules.Builtin
public void OnFinish (object result)
{
if (string.IsNullOrEmpty(m_finishScript))
- return;
-
-
- ParsedResultType level;
- if (result is Exception)
- level = ParsedResultType.Fatal;
- else if (result != null && result is Library.Interface.IBasicResults)
- level = ((IBasicResults)result).ParsedResult;
- else
- level = ParsedResultType.Error;
+ return;
+
+
+ ParsedResultType level;
+ if (result is Exception)
+ level = ParsedResultType.Fatal;
+ else if (result != null && result is Library.Interface.IBasicResults)
+ level = ((IBasicResults)result).ParsedResult;
+ else
+ level = ParsedResultType.Error;
using (TempFile tmpfile = new TempFile())
{
@@ -201,10 +201,10 @@ namespace Duplicati.Library.Modules.Builtin
psi.EnvironmentVariables["DUPLICATI__EVENTNAME"] = eventname;
psi.EnvironmentVariables["DUPLICATI__OPERATIONNAME"] = operationname;
psi.EnvironmentVariables["DUPLICATI__REMOTEURL"] = remoteurl;
- if (level != null)
+ if (level != null)
psi.EnvironmentVariables["DUPLICATI__PARSED_RESULT"] = level.Value.ToString();
-
- if (localpath != null)
+
+ if (localpath != null)
psi.EnvironmentVariables["DUPLICATI__LOCALPATH"] = string.Join(System.IO.Path.PathSeparator.ToString(), localpath);
string stderr = null;
@@ -277,18 +277,18 @@ namespace Duplicati.Library.Modules.Builtin
value = value.Substring(1, value.Length - 2);
}
- if (string.Equals(key, "remoteurl", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(key, "remoteurl", StringComparison.OrdinalIgnoreCase))
{
remoteurl = value;
}
- else if (string.Equals(key, "localpath", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(key, "localpath", StringComparison.OrdinalIgnoreCase))
{
localpath = value.Split(System.IO.Path.PathSeparator);
}
else if (
- string.Equals(key, "eventname", StringComparison.InvariantCultureIgnoreCase) ||
- string.Equals(key, "operationname", StringComparison.InvariantCultureIgnoreCase) ||
- string.Equals(key, "main-action", StringComparison.InvariantCultureIgnoreCase) ||
+ string.Equals(key, "eventname", StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(key, "operationname", StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(key, "main-action", StringComparison.OrdinalIgnoreCase) ||
key == ""
)
{
diff --git a/Duplicati/Library/Modules/Builtin/SendHttpMessage.cs b/Duplicati/Library/Modules/Builtin/SendHttpMessage.cs
index aaa39a66f..fa78ea256 100644
--- a/Duplicati/Library/Modules/Builtin/SendHttpMessage.cs
+++ b/Duplicati/Library/Modules/Builtin/SendHttpMessage.cs
@@ -221,20 +221,20 @@ namespace Duplicati.Library.Modules.Builtin {
return;
//If we do not report this action, then skip
- if (!m_sendAll && !string.Equals(m_operationname, "Backup", StringComparison.InvariantCultureIgnoreCase))
+ if (!m_sendAll && !string.Equals(m_operationname, "Backup", StringComparison.OrdinalIgnoreCase))
return;
- ParsedResultType level;
- if (result is Exception)
- level = ParsedResultType.Fatal;
- else if (result != null && result is Library.Interface.IBasicResults)
- level = ((IBasicResults)result).ParsedResult;
- else
- level = ParsedResultType.Error;
+ ParsedResultType level;
+ if (result is Exception)
+ level = ParsedResultType.Fatal;
+ else if (result != null && result is Library.Interface.IBasicResults)
+ level = ((IBasicResults)result).ParsedResult;
+ else
+ level = ParsedResultType.Error;
- m_parsedresultlevel = level.ToString();
+ m_parsedresultlevel = level.ToString();
- if (string.Equals(m_operationname, "Backup", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(m_operationname, "Backup", StringComparison.OrdinalIgnoreCase))
{
if (!m_levels.Any(x => string.Equals(x, "all", StringComparison.OrdinalIgnoreCase)))
{
@@ -313,7 +313,7 @@ namespace Duplicati.Library.Modules.Builtin {
input = Regex.Replace(input, "\\%REMOTEURL\\%", m_remoteurl ?? "", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
input = Regex.Replace(input, "\\%LOCALPATH\\%", m_localpath == null ? "" : string.Join(System.IO.Path.PathSeparator.ToString(), m_localpath), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
input = Regex.Replace(input, "\\%PARSEDRESULT\\%", m_parsedresultlevel ?? "", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
- if (input.IndexOf("%RESULT%", StringComparison.InvariantCultureIgnoreCase) >= 0)
+ if (input.IndexOf("%RESULT%", StringComparison.OrdinalIgnoreCase) >= 0)
using (TempFile tf = new TempFile())
{
RunScript.SerializeResult(tf, result);
diff --git a/Duplicati/Library/Modules/Builtin/SendJabberMessage.cs b/Duplicati/Library/Modules/Builtin/SendJabberMessage.cs
index 8819ea07d..e57d3bbf3 100644
--- a/Duplicati/Library/Modules/Builtin/SendJabberMessage.cs
+++ b/Duplicati/Library/Modules/Builtin/SendJabberMessage.cs
@@ -219,20 +219,20 @@ namespace Duplicati.Library.Modules.Builtin
return;
//If we do not report this action, then skip
- if (!m_sendAll && !string.Equals(m_operationname, "Backup", StringComparison.InvariantCultureIgnoreCase))
- return;
-
- ParsedResultType level;
- if (result is Exception)
- level = ParsedResultType.Fatal;
- else if (result != null && result is Library.Interface.IBasicResults)
- level = ((IBasicResults)result).ParsedResult;
- else
- level = ParsedResultType.Error;
-
- m_parsedresultlevel = level.ToString();
-
- if (string.Equals(m_operationname, "Backup", StringComparison.InvariantCultureIgnoreCase))
+ if (!m_sendAll && !string.Equals(m_operationname, "Backup", StringComparison.OrdinalIgnoreCase))
+ return;
+
+ ParsedResultType level;
+ if (result is Exception)
+ level = ParsedResultType.Fatal;
+ else if (result != null && result is Library.Interface.IBasicResults)
+ level = ((IBasicResults)result).ParsedResult;
+ else
+ level = ParsedResultType.Error;
+
+ m_parsedresultlevel = level.ToString();
+
+ if (string.Equals(m_operationname, "Backup", StringComparison.OrdinalIgnoreCase))
{
if (!m_levels.Any(x => string.Equals(x, "all", StringComparison.OrdinalIgnoreCase)))
{
@@ -349,7 +349,7 @@ namespace Duplicati.Library.Modules.Builtin
input = Regex.Replace(input, "\\%REMOTEURL\\%", m_remoteurl ?? "", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
input = Regex.Replace(input, "\\%LOCALPATH\\%", m_localpath == null ? "" : string.Join(System.IO.Path.PathSeparator.ToString(), m_localpath), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
input = Regex.Replace(input, "\\%PARSEDRESULT\\%", m_parsedresultlevel ?? "", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
- if (input.IndexOf("%RESULT%", StringComparison.InvariantCultureIgnoreCase) >= 0)
+ if (input.IndexOf("%RESULT%", StringComparison.OrdinalIgnoreCase) >= 0)
using (TempFile tf = new TempFile())
{
RunScript.SerializeResult(tf, result);
diff --git a/Duplicati/Library/Modules/Builtin/SendMail.cs b/Duplicati/Library/Modules/Builtin/SendMail.cs
index c6b1558bc..2afb0a733 100644
--- a/Duplicati/Library/Modules/Builtin/SendMail.cs
+++ b/Duplicati/Library/Modules/Builtin/SendMail.cs
@@ -261,20 +261,20 @@ namespace Duplicati.Library.Modules.Builtin
return;
//If we do not report this action, then skip
- if (!m_sendAll && !string.Equals(m_operationname, "Backup", StringComparison.InvariantCultureIgnoreCase))
- return;
-
- ParsedResultType level;
- if (result is Exception)
- level = ParsedResultType.Fatal;
- else if (result != null && result is Library.Interface.IBasicResults)
- level = ((IBasicResults)result).ParsedResult;
- else
- level = ParsedResultType.Error;
-
+ if (!m_sendAll && !string.Equals(m_operationname, "Backup", StringComparison.OrdinalIgnoreCase))
+ return;
+
+ ParsedResultType level;
+ if (result is Exception)
+ level = ParsedResultType.Fatal;
+ else if (result != null && result is Library.Interface.IBasicResults)
+ level = ((IBasicResults)result).ParsedResult;
+ else
+ level = ParsedResultType.Error;
+
m_parsedresultlevel = level.ToString();
- if (string.Equals(m_operationname, "Backup", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(m_operationname, "Backup", StringComparison.OrdinalIgnoreCase))
{
if (!m_levels.Any(x => string.Equals(x, "all", StringComparison.OrdinalIgnoreCase)))
{
@@ -363,7 +363,7 @@ namespace Duplicati.Library.Modules.Builtin
else
{
servers = (from n in m_server.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)
- let srv = (n == null || n.IndexOf("://", StringComparison.InvariantCultureIgnoreCase) > 0) ? n : "smtp://" + n
+ let srv = (n == null || n.IndexOf("://", StringComparison.OrdinalIgnoreCase) > 0) ? n : "smtp://" + n
where !string.IsNullOrEmpty(srv)
select srv).Distinct().ToList();
}
@@ -452,7 +452,7 @@ namespace Duplicati.Library.Modules.Builtin
}
else
{
- if (input.IndexOf("%RESULT%", StringComparison.InvariantCultureIgnoreCase) >= 0)
+ if (input.IndexOf("%RESULT%", StringComparison.OrdinalIgnoreCase) >= 0)
using(TempFile tf = new TempFile())
{
RunScript.SerializeResult(tf, result);
diff --git a/Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs b/Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs
index 9bf4fab50..f3a9a987a 100644
--- a/Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs
+++ b/Duplicati/Library/SQLiteHelper/DatabaseUpgrader.cs
@@ -226,7 +226,7 @@ namespace Duplicati.Library.SQLiteHelper
throw new Duplicati.Library.Interface.UserInformationException(Strings.DatabaseUpgrader.InvalidVersionError(dbversion, versions.Count, System.IO.Path.GetDirectoryName(sourcefile)));
else if (dbversion < versions.Count) // will need action, collect vars for preparser
{
- preparserVars = new Dictionary<string, IComparable>(StringComparer.InvariantCultureIgnoreCase);
+ preparserVars = new Dictionary<string, IComparable>(StringComparer.OrdinalIgnoreCase);
cmd.CommandText = "SELECT sqlite_version()";
System.Version sqliteversion;
if (Version.TryParse(cmd.ExecuteScalar().ToString(), out sqliteversion))
diff --git a/Duplicati/Library/UsageReporter/OSInfoHelper.cs b/Duplicati/Library/UsageReporter/OSInfoHelper.cs
index f0297cc34..8246300b9 100644
--- a/Duplicati/Library/UsageReporter/OSInfoHelper.cs
+++ b/Duplicati/Library/UsageReporter/OSInfoHelper.cs
@@ -118,18 +118,18 @@ namespace Duplicati.Library.UsageReporter
}
}
- var primary = keys.FirstOrDefault(x => string.Equals(x.Item1, "PRETTY_NAME", StringComparison.InvariantCultureIgnoreCase));
+ var primary = keys.FirstOrDefault(x => string.Equals(x.Item1, "PRETTY_NAME", StringComparison.OrdinalIgnoreCase));
if (primary != null)
return primary.Item2;
- var name = keys.FirstOrDefault(x => string.Equals(x.Item1, "NAME", StringComparison.InvariantCultureIgnoreCase));
- var version = keys.FirstOrDefault(x => string.Equals(x.Item1, "VERSION", StringComparison.InvariantCultureIgnoreCase));
+ var name = keys.FirstOrDefault(x => string.Equals(x.Item1, "NAME", StringComparison.OrdinalIgnoreCase));
+ var version = keys.FirstOrDefault(x => string.Equals(x.Item1, "VERSION", StringComparison.OrdinalIgnoreCase));
- name = name ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "DISTRIB_ID", StringComparison.InvariantCultureIgnoreCase));
- name = name ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "ID", StringComparison.InvariantCultureIgnoreCase));
+ name = name ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "DISTRIB_ID", StringComparison.OrdinalIgnoreCase));
+ name = name ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "ID", StringComparison.OrdinalIgnoreCase));
- version = version ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "DISTRIB_RELEASE", StringComparison.InvariantCultureIgnoreCase));
- version = version ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "VERSION_ID", StringComparison.InvariantCultureIgnoreCase));
+ version = version ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "DISTRIB_RELEASE", StringComparison.OrdinalIgnoreCase));
+ version = version ?? keys.FirstOrDefault(x => string.Equals(x.Item1, "VERSION_ID", StringComparison.OrdinalIgnoreCase));
if (name != null && version != null)
return string.Format("{0} {1}", name.Item2, version.Item2);
diff --git a/Duplicati/Library/UsageReporter/Reporter.cs b/Duplicati/Library/UsageReporter/Reporter.cs
index 1608b52b0..7cbb55b27 100644
--- a/Duplicati/Library/UsageReporter/Reporter.cs
+++ b/Duplicati/Library/UsageReporter/Reporter.cs
@@ -208,7 +208,7 @@ namespace Duplicati.Library.UsageReporter
if (string.IsNullOrWhiteSpace(str))
str = "none";
#endif
- return string.Equals(str, "none", StringComparison.InvariantCultureIgnoreCase) || Utility.Utility.ParseBool(str, false);
+ return string.Equals(str, "none", StringComparison.OrdinalIgnoreCase) || Utility.Utility.ParseBool(str, false);
}
}
diff --git a/Duplicati/Library/Utility/FilterCollector.cs b/Duplicati/Library/Utility/FilterCollector.cs
index 5cdbeed3d..00c733ada 100644
--- a/Duplicati/Library/Utility/FilterCollector.cs
+++ b/Duplicati/Library/Utility/FilterCollector.cs
@@ -39,12 +39,12 @@ namespace Duplicati.Library.Utility
private Dictionary<string, string> DoExtractOptions(List<string> args, Func<string, string, bool> callbackHandler = null)
{
return Library.Utility.CommandLineParser.ExtractOptions(args, (key, value) => {
- if (key.Equals("include", StringComparison.InvariantCultureIgnoreCase))
+ if (key.Equals("include", StringComparison.OrdinalIgnoreCase))
{
m_filters.Add(new Library.Utility.FilterExpression(Library.Utility.Utility.ExpandEnvironmentVariables(value), true));
return false;
}
- else if (key.Equals("exclude", StringComparison.InvariantCultureIgnoreCase))
+ else if (key.Equals("exclude", StringComparison.OrdinalIgnoreCase))
{
m_filters.Add(new Library.Utility.FilterExpression(Library.Utility.Utility.ExpandEnvironmentVariables(value), false));
return false;
diff --git a/Duplicati/Library/Utility/SslCertificateValidator.cs b/Duplicati/Library/Utility/SslCertificateValidator.cs
index 3e5281cad..9b579adee 100644
--- a/Duplicati/Library/Utility/SslCertificateValidator.cs
+++ b/Duplicati/Library/Utility/SslCertificateValidator.cs
@@ -70,7 +70,7 @@ namespace Duplicati.Library.Utility
if (certHash != null && m_validHashes != null)
foreach(var hash in m_validHashes)
{
- if (!string.IsNullOrEmpty(hash) && certHash.Equals(hash, StringComparison.InvariantCultureIgnoreCase))
+ if (!string.IsNullOrEmpty(hash) && certHash.Equals(hash, StringComparison.OrdinalIgnoreCase))
return true;
}
}
diff --git a/Duplicati/Library/Utility/Uri.cs b/Duplicati/Library/Utility/Uri.cs
index af4ea2180..1d4f856dd 100644
--- a/Duplicati/Library/Utility/Uri.cs
+++ b/Duplicati/Library/Utility/Uri.cs
@@ -139,7 +139,7 @@ namespace Duplicati.Library.Utility
if (!m.Success || m.Length != url.Length)
{
var path = url;
- if (path.StartsWith("file://", StringComparison.InvariantCultureIgnoreCase))
+ if (path.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
path = path.Substring("file://".Length);
if (path.IndexOfAny(System.IO.Path.GetInvalidPathChars()) < 0)
@@ -447,9 +447,9 @@ namespace Duplicati.Library.Utility
if (query.StartsWith("?"))
query = query.Substring(1);
if (string.IsNullOrEmpty(query))
- return new NameValueCollection(StringComparer.InvariantCultureIgnoreCase);
+ return new NameValueCollection(StringComparer.OrdinalIgnoreCase);
- var result = new NameValueCollection(StringComparer.InvariantCultureIgnoreCase);
+ var result = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
foreach(System.Text.RegularExpressions.Match m in RE_URLPARAM.Matches(query))
result.Add(UrlDecode(m.Groups["key"].Value), UrlDecode(m.Groups["value"].Success ? m.Groups["value"].Value : ""));
diff --git a/Duplicati/Library/Utility/Utility.cs b/Duplicati/Library/Utility/Utility.cs
index 85d9268c5..d6813fe4c 100644
--- a/Duplicati/Library/Utility/Utility.cs
+++ b/Duplicati/Library/Utility/Utility.cs
@@ -1389,7 +1389,7 @@ namespace Duplicati.Library.Utility
string targetId = string.Format(@"\\?\Volume{{{0}}}\", volumeGuid);
foreach (System.Management.ManagementObject obj in searcher.Get())
{
- if (string.Equals(obj["DeviceID"].ToString(), targetId, StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(obj["DeviceID"].ToString(), targetId, StringComparison.OrdinalIgnoreCase))
{
object driveLetter = obj["DriveLetter"];
if (driveLetter != null)
diff --git a/Duplicati/Server/Database/Connection.cs b/Duplicati/Server/Database/Connection.cs
index e0c44d2ed..4e4de0c8a 100644
--- a/Duplicati/Server/Database/Connection.cs
+++ b/Duplicati/Server/Database/Connection.cs
@@ -375,17 +375,17 @@ namespace Duplicati.Server.Database
if (item.Settings != null)
{
foreach (var s in item.Settings)
- if (string.Equals(s.Name, "--no-encryption", StringComparison.InvariantCultureIgnoreCase))
+ if (string.Equals(s.Name, "--no-encryption", StringComparison.OrdinalIgnoreCase))
disabled_encryption = string.IsNullOrWhiteSpace(s.Value) ? true : Library.Utility.Utility.ParseBool(s.Value, false);
- else if (string.Equals(s.Name, "passphrase", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(s.Name, "passphrase", StringComparison.OrdinalIgnoreCase))
passphrase = s.Value;
- else if (string.Equals(s.Name, "keep-versions", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(s.Name, "keep-versions", StringComparison.OrdinalIgnoreCase))
{
int i;
if (!int.TryParse(s.Value, out i) || i <= 0)
return "Retention value must be a positive integer";
}
- else if (string.Equals(s.Name, "keep-time", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(s.Name, "keep-time", StringComparison.OrdinalIgnoreCase))
{
try
{
@@ -398,7 +398,7 @@ namespace Duplicati.Server.Database
return "Retention value must be a valid timespan";
}
}
- else if (string.Equals(s.Name, "dblock-size", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(s.Name, "dblock-size", StringComparison.OrdinalIgnoreCase))
{
try
{
@@ -411,7 +411,7 @@ namespace Duplicati.Server.Database
return "DBlock value must be a valid size string";
}
}
- else if (string.Equals(s.Name, "--blocksize", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(s.Name, "--blocksize", StringComparison.OrdinalIgnoreCase))
{
try
{
@@ -424,7 +424,7 @@ namespace Duplicati.Server.Database
return "The blocksize value must be a valid size string";
}
}
- else if (string.Equals(s.Name, "--prefix", StringComparison.InvariantCultureIgnoreCase))
+ else if (string.Equals(s.Name, "--prefix", StringComparison.OrdinalIgnoreCase))
{
if (!string.IsNullOrWhiteSpace(s.Value) && s.Value.Contains("-"))
return "The prefix cannot contain hyphens (-)";
@@ -857,28 +857,28 @@ namespace Duplicati.Server.Database
if (tr != null)
tr.Commit();
}
- }
-
- public void UpdateUISettings(string scheme, IDictionary<string, string> values, System.Data.IDbTransaction transaction = null)
- {
- lock (m_lock)
- using (var tr = transaction == null ? m_connection.BeginTransaction() : null)
- {
- OverwriteAndUpdateDb(
- tr,
- @"DELETE FROM ""UIStorage"" WHERE ""Scheme"" = ? AND ""Key"" IN (?)", new object[] { scheme, values.Keys },
- values.Where(x => x.Value != null),
- @"INSERT INTO ""UIStorage"" (""Scheme"", ""Key"", ""Value"") VALUES (?, ?, ?)",
- (f) =>
- {
- return new object[] { scheme, f.Key ?? "", f.Value ?? "" };
- }
- );
-
- if (tr != null)
- tr.Commit();
- }
- }
+ }
+
+ public void UpdateUISettings(string scheme, IDictionary<string, string> values, System.Data.IDbTransaction transaction = null)
+ {
+ lock (m_lock)
+ using (var tr = transaction == null ? m_connection.BeginTransaction() : null)
+ {
+ OverwriteAndUpdateDb(
+ tr,
+ @"DELETE FROM ""UIStorage"" WHERE ""Scheme"" = ? AND ""Key"" IN (?)", new object[] { scheme, values.Keys },
+ values.Where(x => x.Value != null),
+ @"INSERT INTO ""UIStorage"" (""Scheme"", ""Key"", ""Value"") VALUES (?, ?, ?)",
+ (f) =>
+ {
+ return new object[] { scheme, f.Key ?? "", f.Value ?? "" };
+ }
+ );
+
+ if (tr != null)
+ tr.Commit();
+ }
+ }
public TempFile[] GetTempFiles()
{
diff --git a/Duplicati/Server/Database/Schedule.cs b/Duplicati/Server/Database/Schedule.cs
index 806abc2e1..417b0668f 100644
--- a/Duplicati/Server/Database/Schedule.cs
+++ b/Duplicati/Server/Database/Schedule.cs
@@ -38,7 +38,7 @@ namespace Duplicati.Server.Database
return null;
var days = (from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)
- where n.StartsWith("AllowedWeekDays=", StringComparison.InvariantCultureIgnoreCase)
+ where n.StartsWith("AllowedWeekDays=", StringComparison.OrdinalIgnoreCase)
select n.Substring("AllowedWeekDays=".Length).Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries))
.FirstOrDefault();
@@ -59,7 +59,7 @@ namespace Duplicati.Server.Database
string.IsNullOrEmpty(this.Rule) ?
new string[0] :
(from n in this.Rule.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)
- where !n.StartsWith("AllowedWeekDays=", StringComparison.InvariantCultureIgnoreCase)
+ where !n.StartsWith("AllowedWeekDays=", StringComparison.OrdinalIgnoreCase)
select n);
if (value != null && value.Length != 0)
diff --git a/Duplicati/Server/Program.cs b/Duplicati/Server/Program.cs
index f6005cb91..ddc688ebe 100644
--- a/Duplicati/Server/Program.cs
+++ b/Duplicati/Server/Program.cs
@@ -176,10 +176,10 @@ namespace Duplicati.Server
foreach(var s in args)
if (
- s.Equals("help", StringComparison.InvariantCultureIgnoreCase) ||
- s.Equals("/help", StringComparison.InvariantCultureIgnoreCase) ||
- s.Equals("usage", StringComparison.InvariantCultureIgnoreCase) ||
- s.Equals("/usage", StringComparison.InvariantCultureIgnoreCase))
+ s.Equals("help", StringComparison.OrdinalIgnoreCase) ||
+ s.Equals("/help", StringComparison.OrdinalIgnoreCase) ||
+ s.Equals("usage", StringComparison.OrdinalIgnoreCase) ||
+ s.Equals("/usage", StringComparison.OrdinalIgnoreCase))
commandlineOptions["help"] = "";
//If the commandline issues --help, just stop here
@@ -476,7 +476,7 @@ namespace Duplicati.Server
{
#if DEBUG
//debug mode uses a lock file located in the app folder
- DataFolder = StartupPath;
+ DataFolder = StartupPath;
#else
bool portableMode = commandlineOptions.ContainsKey("portable-mode") ? Library.Utility.Utility.ParseBool(commandlineOptions["portable-mode"], true) : false;
@@ -517,7 +517,7 @@ namespace Duplicati.Server
DataFolder = serverDataFolder;
}
#endif
- }
+ }
else
DataFolder = Library.Utility.Utility.AppendDirSeparator(Library.Utility.Utility.ExpandEnvironmentVariables(serverDataFolder).Trim('"'));
@@ -566,9 +566,9 @@ namespace Duplicati.Server
public static void StartOrStopUsageReporter()
{
var disableUsageReporter =
- string.Equals(DataConnection.ApplicationSettings.UsageReporterLevel, "none", StringComparison.InvariantCultureIgnoreCase)
+ string.Equals(DataConnection.ApplicationSettings.UsageReporterLevel, "none", StringComparison.OrdinalIgnoreCase)
||
- string.Equals(DataConnection.ApplicationSettings.UsageReporterLevel, "disabled", StringComparison.InvariantCultureIgnoreCase);
+ string.Equals(DataConnection.ApplicationSettings.UsageReporterLevel, "disabled", StringComparison.OrdinalIgnoreCase);
Library.UsageReporter.ReportType reportLevel;
if (!Enum.TryParse<Library.UsageReporter.ReportType>(DataConnection.ApplicationSettings.UsageReporterLevel, true, out reportLevel))
diff --git a/Duplicati/Server/Runner.cs b/Duplicati/Server/Runner.cs
index 7fa4b984c..fd09be390 100644
--- a/Duplicati/Server/Runner.cs
+++ b/Duplicati/Server/Runner.cs
@@ -85,46 +85,46 @@ namespace Duplicati.Server
}
public long OriginalUploadSpeed { get; set; }
- public long OriginalDownloadSpeed { get; set; }
-
- public void UpdateThrottleSpeed()
- {
- var controller = this.Controller;
- if (controller == null)
- return;
-
- var job_upload_throttle = this.OriginalUploadSpeed <= 0 ? long.MaxValue : this.OriginalUploadSpeed;
- var job_download_throttle = this.OriginalDownloadSpeed <= 0 ? long.MaxValue : this.OriginalDownloadSpeed;
-
- var server_upload_throttle = long.MaxValue;
- var server_download_throttle = long.MaxValue;
-
- try
- {
- if (!string.IsNullOrWhiteSpace(Program.DataConnection.ApplicationSettings.UploadSpeedLimit))
- server_upload_throttle = Duplicati.Library.Utility.Sizeparser.ParseSize(Program.DataConnection.ApplicationSettings.UploadSpeedLimit, "kb");
- }
- catch { }
-
- try
- {
- if (!string.IsNullOrWhiteSpace(Program.DataConnection.ApplicationSettings.DownloadSpeedLimit))
- server_download_throttle = Duplicati.Library.Utility.Sizeparser.ParseSize(Program.DataConnection.ApplicationSettings.DownloadSpeedLimit, "kb");
- }
- catch { }
-
- var upload_throttle = Math.Min(job_upload_throttle, server_upload_throttle);
- var download_throttle = Math.Min(job_download_throttle, server_download_throttle);
-
- if (upload_throttle <= 0 || upload_throttle == long.MaxValue)
- upload_throttle = 0;
-
- if (download_throttle <= 0 || download_throttle == long.MaxValue)
- download_throttle = 0;
-
- controller.MaxUploadSpeed = upload_throttle;
- controller.MaxDownloadSpeed = download_throttle;
- }
+ public long OriginalDownloadSpeed { get; set; }
+
+ public void UpdateThrottleSpeed()
+ {
+ var controller = this.Controller;
+ if (controller == null)
+ return;
+
+ var job_upload_throttle = this.OriginalUploadSpeed <= 0 ? long.MaxValue : this.OriginalUploadSpeed;
+ var job_download_throttle = this.OriginalDownloadSpeed <= 0 ? long.MaxValue : this.OriginalDownloadSpeed;
+
+ var server_upload_throttle = long.MaxValue;
+ var server_download_throttle = long.MaxValue;
+
+ try
+ {
+ if (!string.IsNullOrWhiteSpace(Program.DataConnection.ApplicationSettings.UploadSpeedLimit))
+ server_upload_throttle = Duplicati.Library.Utility.Sizeparser.ParseSize(Program.DataConnection.ApplicationSettings.UploadSpeedLimit, "kb");
+ }
+ catch { }
+
+ try
+ {
+ if (!string.IsNullOrWhiteSpace(Program.DataConnection.ApplicationSettings.DownloadSpeedLimit))
+ server_download_throttle = Duplicati.Library.Utility.Sizeparser.ParseSize(Program.DataConnection.ApplicationSettings.DownloadSpeedLimit, "kb");
+ }
+ catch { }
+
+ var upload_throttle = Math.Min(job_upload_throttle, server_upload_throttle);
+ var download_throttle = Math.Min(job_download_throttle, server_download_throttle);
+
+ if (upload_throttle <= 0 || upload_throttle == long.MaxValue)
+ upload_throttle = 0;
+
+ if (download_throttle <= 0 || download_throttle == long.MaxValue)
+ download_throttle = 0;
+
+ controller.MaxUploadSpeed = upload_throttle;
+ controller.MaxDownloadSpeed = download_throttle;
+ }
private readonly long m_taskID;
@@ -492,7 +492,7 @@ namespace Duplicati.Server
// Pack in the system or task config for easy restore
if (data.Operation == DuplicatiOperation.Backup && options.ContainsKey("store-task-config"))
{
- var all_tasks = string.Equals(options["store-task-config"], "all", StringComparison.InvariantCultureIgnoreCase) || string.Equals(options["store-task-config"], "*", StringComparison.InvariantCultureIgnoreCase);
+ var all_tasks = string.Equals(options["store-task-config"], "all", StringComparison.OrdinalIgnoreCase) || string.Equals(options["store-task-config"], "*", StringComparison.OrdinalIgnoreCase);
var this_task = Duplicati.Library.Utility.Utility.ParseBool(options["store-task-config"], false);
options.Remove("store-task-config");
@@ -538,19 +538,19 @@ namespace Duplicati.Server
if (options.ContainsKey("throttle-upload"))
((RunnerData)data).OriginalUploadSpeed = Duplicati.Library.Utility.Sizeparser.ParseSize(options["throttle-upload"], "kb");
}
- catch { }
-
- try
- {
- if (options.ContainsKey("throttle-download"))
- ((RunnerData)data).OriginalDownloadSpeed = Duplicati.Library.Utility.Sizeparser.ParseSize(options["throttle-download"], "kb");
- }
- catch { }
-
- ((RunnerData)data).Controller = controller;
- data.UpdateThrottleSpeed();
-
- switch (data.Operation)
+ catch { }
+
+ try
+ {
+ if (options.ContainsKey("throttle-download"))
+ ((RunnerData)data).OriginalDownloadSpeed = Duplicati.Library.Utility.Sizeparser.ParseSize(options["throttle-download"], "kb");
+ }
+ catch { }
+
+ ((RunnerData)data).Controller = controller;
+ data.UpdateThrottleSpeed();
+
+ switch (data.Operation)
{
case DuplicatiOperation.Backup:
{
@@ -836,12 +836,12 @@ namespace Duplicati.Server
if (options.TryGetValue("enable-module", out enabledModules))
{
var emods = (enabledModules ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- options["enable-module"] = string.Join(",", emods.Where(x => module.Equals(x, StringComparison.InvariantCultureIgnoreCase)));
+ options["enable-module"] = string.Join(",", emods.Where(x => module.Equals(x, StringComparison.OrdinalIgnoreCase)));
}
options.TryGetValue("disable-module", out disabledModules);
var mods = (disabledModules ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- options["disable-module"] = string.Join(",", mods.Union(new string[] { module }).Distinct(StringComparer.InvariantCultureIgnoreCase));
+ options["disable-module"] = string.Join(",", mods.Union(new string[] { module }).Distinct(StringComparer.OrdinalIgnoreCase));
}
private static Dictionary<string, string> ApplyOptions(Duplicati.Server.Serialization.Interface.IBackup backup, DuplicatiOperation mode, Dictionary<string, string> options)
diff --git a/Duplicati/Server/SpecialFolders.cs b/Duplicati/Server/SpecialFolders.cs
index 52285b865..fc7b31c9f 100644
--- a/Duplicati/Server/SpecialFolders.cs
+++ b/Duplicati/Server/SpecialFolders.cs
@@ -24,8 +24,8 @@ namespace Duplicati.Server
public static class SpecialFolders
{
public static readonly Serializable.TreeNode[] Nodes;
- private static readonly Dictionary<string, string> PathMap = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
- private static readonly Dictionary<string, string> DisplayMap = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
+ private static readonly Dictionary<string, string> PathMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ private static readonly Dictionary<string, string> DisplayMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
public static string ExpandEnvironmentVariables(string path)
{
diff --git a/Duplicati/Server/WebServer/AuthenticationHandler.cs b/Duplicati/Server/WebServer/AuthenticationHandler.cs
index afa0ea37d..bd8339e4d 100644
--- a/Duplicati/Server/WebServer/AuthenticationHandler.cs
+++ b/Duplicati/Server/WebServer/AuthenticationHandler.cs
@@ -153,7 +153,7 @@ namespace Duplicati.Server.WebServer
Tuple<DateTime, string> tmpTuple;
DateTime tmpDateTime;
- if (LOGOUT_SCRIPT_URI.Equals(request.Uri.AbsolutePath, StringComparison.InvariantCultureIgnoreCase))
+ if (LOGOUT_SCRIPT_URI.Equals(request.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase))
{
if (!string.IsNullOrWhiteSpace(auth_token))
{
@@ -166,7 +166,7 @@ namespace Duplicati.Server.WebServer
return true;
}
- else if (LOGIN_SCRIPT_URI.Equals(request.Uri.AbsolutePath, StringComparison.InvariantCultureIgnoreCase))
+ else if (LOGIN_SCRIPT_URI.Equals(request.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase))
{
// Remove expired nonces
foreach(var k in (from n in m_activeNonces where DateTime.UtcNow > n.Value.Item1 select n.Key))
@@ -271,11 +271,11 @@ namespace Duplicati.Server.WebServer
}
var limitedAccess =
- request.Uri.AbsolutePath.StartsWith(RESTHandler.API_URI_PATH, StringComparison.InvariantCultureIgnoreCase)
+ request.Uri.AbsolutePath.StartsWith(RESTHandler.API_URI_PATH, StringComparison.OrdinalIgnoreCase)
;
// Override to allow the CAPTCHA call to go through
- if (request.Uri.AbsolutePath.StartsWith(CAPTCHA_IMAGE_URI, StringComparison.InvariantCultureIgnoreCase) && request.Method == "GET")
+ if (request.Uri.AbsolutePath.StartsWith(CAPTCHA_IMAGE_URI, StringComparison.OrdinalIgnoreCase) && request.Method == "GET")
limitedAccess = false;
if (limitedAccess)
@@ -323,7 +323,7 @@ namespace Duplicati.Server.WebServer
}
}
- if ("/".Equals(request.Uri.AbsolutePath, StringComparison.InvariantCultureIgnoreCase) || "/index.html".Equals(request.Uri.AbsolutePath, StringComparison.InvariantCultureIgnoreCase))
+ if ("/".Equals(request.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase) || "/index.html".Equals(request.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase))
{
response.Redirect("/login.html");
return true;
diff --git a/Duplicati/Server/WebServer/RESTHandler.cs b/Duplicati/Server/WebServer/RESTHandler.cs
index 45057e40f..f006a2711 100644
--- a/Duplicati/Server/WebServer/RESTHandler.cs
+++ b/Duplicati/Server/WebServer/RESTHandler.cs
@@ -27,7 +27,7 @@ namespace Duplicati.Server.WebServer
public const string API_URI_PATH = "/api/v1";
public static readonly int API_URI_SEGMENTS = API_URI_PATH.Split(new char[] {'/'}).Length;
- private static readonly Dictionary<string, IRESTMethod> _modules = new Dictionary<string, IRESTMethod>(StringComparer.InvariantCultureIgnoreCase);
+ private static readonly Dictionary<string, IRESTMethod> _modules = new Dictionary<string, IRESTMethod>(StringComparer.OrdinalIgnoreCase);
public static IDictionary<string, IRESTMethod> Modules { get { return _modules; } }
@@ -98,7 +98,7 @@ namespace Duplicati.Server.WebServer
var opts = x.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
var lang = opts.FirstOrDefault();
var weight =
- opts.Where(y => y.StartsWith("q=", StringComparison.InvariantCultureIgnoreCase))
+ opts.Where(y => y.StartsWith("q=", StringComparison.OrdinalIgnoreCase))
.Select(y =>
{
float f;
@@ -229,7 +229,7 @@ namespace Duplicati.Server.WebServer
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
{
- if (!request.Uri.AbsolutePath.StartsWith(API_URI_PATH, StringComparison.InvariantCultureIgnoreCase))
+ if (!request.Uri.AbsolutePath.StartsWith(API_URI_PATH, StringComparison.OrdinalIgnoreCase))
return false;
var module = request.Uri.Segments.Skip(API_URI_SEGMENTS).FirstOrDefault();
diff --git a/Duplicati/Server/WebServer/RESTMethods/Backup.cs b/Duplicati/Server/WebServer/RESTMethods/Backup.cs
index 014d7f971..9015c7753 100644
--- a/Duplicati/Server/WebServer/RESTMethods/Backup.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/Backup.cs
@@ -83,7 +83,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
var r = Runner.Run(Runner.CreateTask(DuplicatiOperation.List, backup, extra), false) as Duplicati.Library.Interface.IListResults;
- if (r.EncryptedFiles && backup.Settings.Any(x => string.Equals("--no-encryption", x.Name, StringComparison.InvariantCultureIgnoreCase)))
+ if (r.EncryptedFiles && backup.Settings.Any(x => string.Equals("--no-encryption", x.Name, StringComparison.OrdinalIgnoreCase)))
info.ReportServerError("encrypted-storage");
else
info.OutputOK(r.Filesets);
@@ -539,7 +539,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
return;
}
- if (Program.DataConnection.Backups.Where(x => x.Name.Equals(data.Backup.Name, StringComparison.InvariantCultureIgnoreCase) && x.ID != data.Backup.ID).Any())
+ if (Program.DataConnection.Backups.Where(x => x.Name.Equals(data.Backup.Name, StringComparison.OrdinalIgnoreCase) && x.ID != data.Backup.ID).Any())
{
info.ReportClientError("There already exists a backup with the name: " + data.Backup.Name);
return;
diff --git a/Duplicati/Server/WebServer/RESTMethods/Backups.cs b/Duplicati/Server/WebServer/RESTMethods/Backups.cs
index 4e8353226..bc9c107e8 100644
--- a/Duplicati/Server/WebServer/RESTMethods/Backups.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/Backups.cs
@@ -103,10 +103,10 @@ namespace Duplicati.Server.WebServer.RESTMethods
{
var basename = ipx.Backup.Name;
var c = 0;
- while (c++ < 100 && Program.DataConnection.Backups.Where(x => x.Name.Equals(ipx.Backup.Name, StringComparison.InvariantCultureIgnoreCase)).Any())
+ while (c++ < 100 && Program.DataConnection.Backups.Where(x => x.Name.Equals(ipx.Backup.Name, StringComparison.OrdinalIgnoreCase)).Any())
ipx.Backup.Name = basename + " (" + c.ToString() + ")";
- if (Program.DataConnection.Backups.Where(x => x.Name.Equals(ipx.Backup.Name, StringComparison.InvariantCultureIgnoreCase)).Any())
+ if (Program.DataConnection.Backups.Where(x => x.Name.Equals(ipx.Backup.Name, StringComparison.OrdinalIgnoreCase)).Any())
{
info.BodyWriter.SetOK();
info.Response.ContentType = "text/html";
@@ -148,7 +148,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
public void POST(string key, RequestInfo info)
{
- if ("import".Equals(key, StringComparison.InvariantCultureIgnoreCase))
+ if ("import".Equals(key, StringComparison.OrdinalIgnoreCase))
{
ImportBackup(info);
return;
@@ -194,7 +194,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
lock(Program.DataConnection.m_lock)
{
- if (Program.DataConnection.Backups.Where(x => x.Name.Equals(data.Backup.Name, StringComparison.InvariantCultureIgnoreCase)).Any())
+ if (Program.DataConnection.Backups.Where(x => x.Name.Equals(data.Backup.Name, StringComparison.OrdinalIgnoreCase)).Any())
{
info.ReportClientError("There already exists a backup with the name: " + data.Backup.Name);
return;
diff --git a/Duplicati/Server/WebServer/RESTMethods/Captcha.cs b/Duplicati/Server/WebServer/RESTMethods/Captcha.cs
index 76d3512b0..4bf51fb2c 100644
--- a/Duplicati/Server/WebServer/RESTMethods/Captcha.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/Captcha.cs
@@ -53,7 +53,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
if (tp.Attempts > 0)
tp.Attempts--;
- return tp.Attempts >= 0 && string.Equals(tp.Answer, answer, StringComparison.InvariantCultureIgnoreCase) && tp.Target == target && tp.Expires >= DateTime.Now;
+ return tp.Attempts >= 0 && string.Equals(tp.Answer, answer, StringComparison.OrdinalIgnoreCase) && tp.Target == target && tp.Expires >= DateTime.Now;
}
}
diff --git a/Duplicati/Server/WebServer/RESTMethods/CommandLine.cs b/Duplicati/Server/WebServer/RESTMethods/CommandLine.cs
index 764ff6a1a..72ccc6bd0 100644
--- a/Duplicati/Server/WebServer/RESTMethods/CommandLine.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/CommandLine.cs
@@ -146,7 +146,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
}
else
{
- if (!key.EndsWith("/abort", StringComparison.InvariantCultureIgnoreCase))
+ if (!key.EndsWith("/abort", StringComparison.OrdinalIgnoreCase))
{
info.ReportClientError("Only abort commands are allowed");
return;
diff --git a/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs b/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs
index e0fdda807..dd44dfe3a 100644
--- a/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/Filesystem.cs
@@ -54,7 +54,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
if (ix > 0)
{
var tk = path.Substring(0, ix + 1);
- var node = SpecialFolders.Nodes.Where(x => x.id.Equals(tk, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
+ var node = SpecialFolders.Nodes.Where(x => x.id.Equals(tk, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (node != null)
{
specialpath = node.resolvedpath;
@@ -73,7 +73,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
if (!string.IsNullOrWhiteSpace(command))
{
- if ("validate".Equals(command, StringComparison.InvariantCultureIgnoreCase))
+ if ("validate".Equals(command, StringComparison.OrdinalIgnoreCase))
{
try
{
diff --git a/Duplicati/Server/WebServer/RESTMethods/LogData.cs b/Duplicati/Server/WebServer/RESTMethods/LogData.cs
index 177330575..552cc2a7c 100644
--- a/Duplicati/Server/WebServer/RESTMethods/LogData.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/LogData.cs
@@ -14,12 +14,98 @@
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-using System; using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
namespace Duplicati.Server.WebServer.RESTMethods
{
public class LogData : IRESTMethodGET, IRESTMethodDocumented
- { public void GET(string key, RequestInfo info) { if ("poll".Equals(key, StringComparison.InvariantCultureIgnoreCase)) { var input = info.Request.QueryString; var level_str = input["level"].Value ?? ""; var id_str = input["id"].Value ?? ""; Library.Logging.LogMessageType level; long id; long.TryParse(id_str, out id); Enum.TryParse(level_str, true, out level); info.OutputOK(Program.LogHandler.AfterID(id, level)); } else { List<Dictionary<string, object>> res = null; Program.DataConnection.ExecuteWithCommand(x => { res = DumpTable(x, "ErrorLog", "Timestamp", info.Request.QueryString["offset"].Value, info.Request.QueryString["pagesize"].Value); }); info.OutputOK(res); } } public static List<Dictionary<string, object>> DumpTable(System.Data.IDbCommand cmd, string tablename, string pagingfield, string offset_str, string pagesize_str) { var result = new List<Dictionary<string, object>>(); long pagesize; if (!long.TryParse(pagesize_str, out pagesize)) pagesize = 100; pagesize = Math.Max(10, Math.Min(500, pagesize)); cmd.CommandText = "SELECT * FROM \"" + tablename + "\""; long offset = 0; if (!string.IsNullOrWhiteSpace(offset_str) && long.TryParse(offset_str, out offset) && !string.IsNullOrEmpty(pagingfield)) { var p = cmd.CreateParameter(); p.Value = offset; cmd.Parameters.Add(p); cmd.CommandText += " WHERE \"" + pagingfield + "\" < ?"; } if (!string.IsNullOrEmpty(pagingfield)) cmd.CommandText += " ORDER BY \"" + pagingfield + "\" DESC"; cmd.CommandText += " LIMIT " + pagesize.ToString(); using(var rd = cmd.ExecuteReader()) { var names = new List<string>(); for(var i = 0; i < rd.FieldCount; i++) names.Add(rd.GetName(i)); while (rd.Read()) { var dict = new Dictionary<string, object>(); for(int i = 0; i < names.Count; i++) dict[names[i]] = rd.GetValue(i); result.Add(dict); } } return result; } public string Description { get { return "Retrieves system log data"; } } public IEnumerable<KeyValuePair<string, Type>> Types { get { return new KeyValuePair<string, Type>[] { new KeyValuePair<string, Type>(HttpServer.Method.Get, typeof(Dictionary<string, string>[])), }; } }
+ {
+ public void GET(string key, RequestInfo info)
+ {
+ if ("poll".Equals(key, StringComparison.OrdinalIgnoreCase))
+ {
+ var input = info.Request.QueryString;
+ var level_str = input["level"].Value ?? "";
+ var id_str = input["id"].Value ?? "";
+
+ Library.Logging.LogMessageType level;
+ long id;
+
+ long.TryParse(id_str, out id);
+ Enum.TryParse(level_str, true, out level);
+
+ info.OutputOK(Program.LogHandler.AfterID(id, level));
+ }
+ else
+ {
+
+ List<Dictionary<string, object>> res = null;
+ Program.DataConnection.ExecuteWithCommand(x =>
+ {
+ res = DumpTable(x, "ErrorLog", "Timestamp", info.Request.QueryString["offset"].Value, info.Request.QueryString["pagesize"].Value);
+ });
+
+ info.OutputOK(res);
+ }
+ }
+
+
+ public static List<Dictionary<string, object>> DumpTable(System.Data.IDbCommand cmd, string tablename, string pagingfield, string offset_str, string pagesize_str)
+ {
+ var result = new List<Dictionary<string, object>>();
+
+ long pagesize;
+ if (!long.TryParse(pagesize_str, out pagesize))
+ pagesize = 100;
+
+ pagesize = Math.Max(10, Math.Min(500, pagesize));
+
+ cmd.CommandText = "SELECT * FROM \"" + tablename + "\"";
+ long offset = 0;
+ if (!string.IsNullOrWhiteSpace(offset_str) && long.TryParse(offset_str, out offset) && !string.IsNullOrEmpty(pagingfield))
+ {
+ var p = cmd.CreateParameter();
+ p.Value = offset;
+ cmd.Parameters.Add(p);
+
+ cmd.CommandText += " WHERE \"" + pagingfield + "\" < ?";
+ }
+
+ if (!string.IsNullOrEmpty(pagingfield))
+ cmd.CommandText += " ORDER BY \"" + pagingfield + "\" DESC";
+ cmd.CommandText += " LIMIT " + pagesize.ToString();
+
+ using(var rd = cmd.ExecuteReader())
+ {
+ var names = new List<string>();
+ for(var i = 0; i < rd.FieldCount; i++)
+ names.Add(rd.GetName(i));
+
+ while (rd.Read())
+ {
+ var dict = new Dictionary<string, object>();
+ for(int i = 0; i < names.Count; i++)
+ dict[names[i]] = rd.GetValue(i);
+
+ result.Add(dict);
+ }
+ }
+
+ return result;
+ }
+
+ public string Description { get { return "Retrieves system log data"; } }
+
+ public IEnumerable<KeyValuePair<string, Type>> Types
+ {
+ get
+ {
+ return new KeyValuePair<string, Type>[] {
+ new KeyValuePair<string, Type>(HttpServer.Method.Get, typeof(Dictionary<string, string>[])),
+ };
+ }
+ }
}
}
diff --git a/Duplicati/Server/WebServer/RESTMethods/ServerSetting.cs b/Duplicati/Server/WebServer/RESTMethods/ServerSetting.cs
index 1b3c08307..d0adad452 100644
--- a/Duplicati/Server/WebServer/RESTMethods/ServerSetting.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/ServerSetting.cs
@@ -30,7 +30,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
return;
}
- if (key.Equals("server-ssl-certificate", StringComparison.InvariantCultureIgnoreCase) || key.Equals("ServerSSLCertificate", StringComparison.InvariantCultureIgnoreCase))
+ if (key.Equals("server-ssl-certificate", StringComparison.OrdinalIgnoreCase) || key.Equals("ServerSSLCertificate", StringComparison.OrdinalIgnoreCase))
{
info.OutputOK(Program.DataConnection.ApplicationSettings.ServerSSLCertificate == null ? "False" : "True");
return;
@@ -38,7 +38,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
if (key.StartsWith("--", StringComparison.Ordinal))
{
- var prop = Program.DataConnection.Settings.FirstOrDefault(x => string.Equals(key, x.Name, StringComparison.InvariantCultureIgnoreCase));
+ var prop = Program.DataConnection.Settings.FirstOrDefault(x => string.Equals(key, x.Name, StringComparison.OrdinalIgnoreCase));
info.OutputOK(prop == null ? null : prop.Value);
}
else
@@ -57,19 +57,19 @@ namespace Duplicati.Server.WebServer.RESTMethods
{
info.OutputError(null, System.Net.HttpStatusCode.BadRequest, "Key is missing");
return;
- }
-
- if (key.Equals("server-ssl-certificate", StringComparison.InvariantCultureIgnoreCase) || key.Equals("ServerSSLCertificate", StringComparison.InvariantCultureIgnoreCase))
- {
- info.OutputError(null, System.Net.HttpStatusCode.BadRequest, "Can only update SSL certificate from commandline");
- return;
- }
-
- if (key.StartsWith("--", StringComparison.Ordinal))
+ }
+
+ if (key.Equals("server-ssl-certificate", StringComparison.OrdinalIgnoreCase) || key.Equals("ServerSSLCertificate", StringComparison.OrdinalIgnoreCase))
+ {
+ info.OutputError(null, System.Net.HttpStatusCode.BadRequest, "Can only update SSL certificate from commandline");
+ return;
+ }
+
+ if (key.StartsWith("--", StringComparison.Ordinal))
{
var settings = Program.DataConnection.Settings.ToList();
- var prop = settings.Where(x => string.Equals(key, x.Name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
+ var prop = settings.Where(x => string.Equals(key, x.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (prop == null)
settings.Add(prop = new Database.Setting() { Name = key, Value = info.Request.Form["data"].Value });
else
diff --git a/Duplicati/Server/WebServer/RESTMethods/WebModule.cs b/Duplicati/Server/WebServer/RESTMethods/WebModule.cs
index 108353938..5145653af 100644
--- a/Duplicati/Server/WebServer/RESTMethods/WebModule.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/WebModule.cs
@@ -14,14 +14,27 @@
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-using System; using System.Linq;
+using System;
+using System.Linq;
namespace Duplicati.Server.WebServer.RESTMethods
{
public class WebModule : IRESTMethodPOST
{
public void POST(string key, RequestInfo info)
- { var m = Duplicati.Library.DynamicLoader.WebLoader.Modules.Where(x => x.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (m == null) { info.ReportClientError(string.Format("No such command {0}", key), System.Net.HttpStatusCode.NotFound); return; } info.OutputOK(new { Status = "OK", Result = m.Execute(info.Request.Form.Where(x => !x.Name.Equals("command", StringComparison.InvariantCultureIgnoreCase) ).ToDictionary(x => x.Name, x => x.Value)) });
+ {
+ var m = Duplicati.Library.DynamicLoader.WebLoader.Modules.Where(x => x.Key.Equals(key, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
+ if (m == null)
+ {
+ info.ReportClientError(string.Format("No such command {0}", key), System.Net.HttpStatusCode.NotFound);
+ return;
+ }
+
+ info.OutputOK(new {
+ Status = "OK",
+ Result = m.Execute(info.Request.Form.Where(x => !x.Name.Equals("command", StringComparison.OrdinalIgnoreCase)
+ ).ToDictionary(x => x.Name, x => x.Value))
+ });
}
}
}
diff --git a/Duplicati/Server/WebServer/Server.cs b/Duplicati/Server/WebServer/Server.cs
index 6702d2536..7b4016879 100644
--- a/Duplicati/Server/WebServer/Server.cs
+++ b/Duplicati/Server/WebServer/Server.cs
@@ -107,7 +107,7 @@ namespace Duplicati.Server.WebServer
if (string.IsNullOrWhiteSpace(interfacestring))
interfacestring = DEFAULT_OPTION_INTERFACE;
- if (interfacestring.Trim() == "*" || interfacestring.Trim().Equals("any", StringComparison.InvariantCultureIgnoreCase) || interfacestring.Trim().Equals("all", StringComparison.InvariantCultureIgnoreCase))
+ if (interfacestring.Trim() == "*" || interfacestring.Trim().Equals("any", StringComparison.OrdinalIgnoreCase) || interfacestring.Trim().Equals("all", StringComparison.OrdinalIgnoreCase))
listenInterface = System.Net.IPAddress.Any;
else if (interfacestring.Trim() == "loopback")
listenInterface = System.Net.IPAddress.Loopback;
diff --git a/Duplicati/Server/WebServer/SynologyAuthenticationHandler.cs b/Duplicati/Server/WebServer/SynologyAuthenticationHandler.cs
index f85f3cd75..37c49f084 100644
--- a/Duplicati/Server/WebServer/SynologyAuthenticationHandler.cs
+++ b/Duplicati/Server/WebServer/SynologyAuthenticationHandler.cs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -23,34 +23,34 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using HttpServer.HttpModules;
-namespace Duplicati.Server.WebServer
+namespace Duplicati.Server.WebServer
{
/// <summary>
/// Helper class for enforcing the built-in authentication on Synology DSM
- /// </summary>
- public class SynologyAuthenticationHandler : HttpModule
+ /// </summary>
+ public class SynologyAuthenticationHandler : HttpModule
{
/// <summary>
/// The path to the login.cgi script
- /// </summary>
+ /// </summary>
private readonly string LOGIN_CGI = GetEnvArg("SYNO_LOGIN_CGI", "/usr/syno/synoman/webman/login.cgi");
/// <summary>
/// The path to the authenticate.cgi script
- /// </summary>
- private readonly string AUTH_CGI = GetEnvArg("SYNO_AUTHENTICATE_CGI", "/usr/syno/synoman/webman/modules/authenticate.cgi");
+ /// </summary>
+ private readonly string AUTH_CGI = GetEnvArg("SYNO_AUTHENTICATE_CGI", "/usr/syno/synoman/webman/modules/authenticate.cgi");
/// <summary>
/// A flag indicating if only admins are allowed
- /// </summary>
- private readonly bool ADMIN_ONLY = !(GetEnvArg("SYNO_ALL_USERS", "0") == "1");
+ /// </summary>
+ private readonly bool ADMIN_ONLY = !(GetEnvArg("SYNO_ALL_USERS", "0") == "1");
/// <summary>
/// A flag indicating if the XSRF token should be fetched automatically
- /// </summary>
- private readonly bool AUTO_XSRF = GetEnvArg("SYNO_AUTO_XSRF", "1") == "1";
+ /// </summary>
+ private readonly bool AUTO_XSRF = GetEnvArg("SYNO_AUTO_XSRF", "1") == "1";
/// <summary>
/// A flag indicating that the auth-module is fully disabled
- /// </summary>
- private readonly bool FULLY_DISABLED;
+ /// </summary>
+ private readonly bool FULLY_DISABLED;
/// <summary>
/// Re-evealuate the logins periodically to ensure it is still valid
@@ -65,12 +65,12 @@ namespace Duplicati.Server.WebServer
/// <summary>
/// The loca guarding the login cache
/// </summary>
- private object m_lock = new object();
+ private object m_lock = new object();
/// <summary>
/// Initializes a new instance of the <see cref="T:Duplicati.Server.WebServer.SynologyAuthenticationHandler"/> class.
- /// </summary>
- public SynologyAuthenticationHandler()
+ /// </summary>
+ public SynologyAuthenticationHandler()
{
Console.WriteLine("Enabling Synology integrated authentication handler");
var disable = false;
@@ -78,15 +78,15 @@ namespace Duplicati.Server.WebServer
{
Console.WriteLine("Disabling webserver as the login script is not found: {0}", LOGIN_CGI);
disable = true;
- }
- if (!File.Exists(AUTH_CGI))
- {
- Console.WriteLine("Disabling webserver as the auth script is not found: {0}", AUTH_CGI);
- disable = true;
- }
+ }
+ if (!File.Exists(AUTH_CGI))
+ {
+ Console.WriteLine("Disabling webserver as the auth script is not found: {0}", AUTH_CGI);
+ disable = true;
+ }
- FULLY_DISABLED = disable;
- }
+ FULLY_DISABLED = disable;
+ }
/// <summary>
/// Processes the request
@@ -105,26 +105,26 @@ namespace Duplicati.Server.WebServer
}
var limitedAccess =
- request.Uri.AbsolutePath.StartsWith(RESTHandler.API_URI_PATH, StringComparison.InvariantCultureIgnoreCase)
+ request.Uri.AbsolutePath.StartsWith(RESTHandler.API_URI_PATH, StringComparison.OrdinalIgnoreCase)
||
- request.Uri.AbsolutePath.StartsWith(AuthenticationHandler.LOGIN_SCRIPT_URI, StringComparison.InvariantCultureIgnoreCase)
- ||
- request.Uri.AbsolutePath.StartsWith(AuthenticationHandler.LOGOUT_SCRIPT_URI, StringComparison.InvariantCultureIgnoreCase);
+ request.Uri.AbsolutePath.StartsWith(AuthenticationHandler.LOGIN_SCRIPT_URI, StringComparison.OrdinalIgnoreCase)
+ ||
+ request.Uri.AbsolutePath.StartsWith(AuthenticationHandler.LOGOUT_SCRIPT_URI, StringComparison.OrdinalIgnoreCase);
if (!limitedAccess)
return false;
-
- var tmpenv = new Dictionary<string, string>();
+
+ var tmpenv = new Dictionary<string, string>();
tmpenv["REMOTE_ADDR"] = request.RemoteEndPoint.Address.ToString();
tmpenv["REMOTE_PORT"] = request.RemoteEndPoint.Port.ToString();
if (!string.IsNullOrWhiteSpace(request.Headers["X-Real-IP"]))
- tmpenv["REMOTE_ADDR"] = request.Headers["X-Real-IP"];
- if (!string.IsNullOrWhiteSpace(request.Headers["X-Real-IP"]))
- tmpenv["REMOTE_PORT"] = request.Headers["X-Real-Port"];
-
- var loginid = request.Cookies["id"]?.Value;
+ tmpenv["REMOTE_ADDR"] = request.Headers["X-Real-IP"];
+ if (!string.IsNullOrWhiteSpace(request.Headers["X-Real-IP"]))
+ tmpenv["REMOTE_PORT"] = request.Headers["X-Real-Port"];
+
+ var loginid = request.Cookies["id"]?.Value;
if (!string.IsNullOrWhiteSpace(loginid))
tmpenv["HTTP_COOKIE"] = "id=" + loginid;
@@ -142,8 +142,8 @@ namespace Duplicati.Server.WebServer
}
if (string.IsNullOrWhiteSpace(xsrftoken) && AUTO_XSRF)
- {
- var authre = new Regex(@"""SynoToken""\s?\:\s?""(?<token>[^""]+)""");
+ {
+ var authre = new Regex(@"""SynoToken""\s?\:\s?""(?<token>[^""]+)""");
try
{
var resp = ShellExec(LOGIN_CGI, env: tmpenv).Result;
@@ -156,60 +156,60 @@ namespace Duplicati.Server.WebServer
}
catch (Exception ex)
{
- response.Status = System.Net.HttpStatusCode.InternalServerError;
- response.Reason = "The system is incorrectly configured";
- return true;
-
- }
- }
-
- if (!string.IsNullOrWhiteSpace(xsrftoken))
- tmpenv["HTTP_X_SYNO_TOKEN"] = xsrftoken;
-
- cachestring = BuildCacheKey(tmpenv, xsrftoken);
-
- var username = GetEnvArg("SYNO_USERNAME");
- if (string.IsNullOrWhiteSpace(username))
- {
+ response.Status = System.Net.HttpStatusCode.InternalServerError;
+ response.Reason = "The system is incorrectly configured";
+ return true;
+
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(xsrftoken))
+ tmpenv["HTTP_X_SYNO_TOKEN"] = xsrftoken;
+
+ cachestring = BuildCacheKey(tmpenv, xsrftoken);
+
+ var username = GetEnvArg("SYNO_USERNAME");
+ if (string.IsNullOrWhiteSpace(username))
+ {
try
{
username = ShellExec(AUTH_CGI, shell: false, exitcode: 0, env: tmpenv).Result;
}
catch (Exception ex)
- {
- response.Status = System.Net.HttpStatusCode.InternalServerError;
- response.Reason = "The system is incorrectly configured";
- return true;
- }
- }
+ {
+ response.Status = System.Net.HttpStatusCode.InternalServerError;
+ response.Reason = "The system is incorrectly configured";
+ return true;
+ }
+ }
if (string.IsNullOrWhiteSpace(username))
- {
- response.Status = System.Net.HttpStatusCode.Forbidden;
- response.Reason = "Permission denied, not logged in";
- return true;
- }
-
- username = username.Trim();
-
- if (ADMIN_ONLY)
- {
- var groups = GetEnvArg("SYNO_GROUP_IDS");
-
- if (string.IsNullOrWhiteSpace(groups))
+ {
+ response.Status = System.Net.HttpStatusCode.Forbidden;
+ response.Reason = "Permission denied, not logged in";
+ return true;
+ }
+
+ username = username.Trim();
+
+ if (ADMIN_ONLY)
+ {
+ var groups = GetEnvArg("SYNO_GROUP_IDS");
+
+ if (string.IsNullOrWhiteSpace(groups))
groups = ShellExec("id", "-G '" + username.Trim().Replace("'", "\\'") + "'", exitcode: 0).Result ?? string.Empty;
if (!groups.Split(new char[] { ' ' }).Contains("101"))
{
- response.Status = System.Net.HttpStatusCode.Forbidden;
- response.Reason = "Administrator login required";
- return true;
- }
- }
+ response.Status = System.Net.HttpStatusCode.Forbidden;
+ response.Reason = "Administrator login required";
+ return true;
+ }
+ }
// We are now authenticated, add to cache
- m_logincache[cachestring] = DateTime.Now + CACHE_TIMEOUT;
- return false;
- }
+ m_logincache[cachestring] = DateTime.Now + CACHE_TIMEOUT;
+ return false;
+ }
/// <summary>
/// Builds a cache key from the environment data
@@ -223,37 +223,37 @@ namespace Duplicati.Server.WebServer
return null;
return string.Format("{0}:{1}/{2}?{3}", values["REMOTE_ADDR"], values["REMOTE_PORT"], values["HTTP_COOKIE"], xsrftoken);
- }
-
- /// <summary>
- /// Runs an external command
- /// </summary>
- /// <returns>The stdout data.</returns>
- /// <param name="command">The executable</param>
- /// <param name="args">The executable and the arguments.</param>
- /// <param name="shell">If set to <c>true</c> use the shell context for execution.</param>
- /// <param name="exitcode">Set the value to check for a particular exitcode.</param>
- private static async Task<string> ShellExec(string command, string args = null, bool shell = false, int exitcode = -1, Dictionary<string, string> env = null)
- {
- var psi = new ProcessStartInfo()
- {
- FileName = command,
- Arguments = shell ? null : args,
- UseShellExecute = false,
- RedirectStandardInput = shell,
- RedirectStandardOutput = true
- };
-
- if (env != null)
- foreach (var pk in env)
- psi.EnvironmentVariables[pk.Key] = pk.Value;
-
- using (var p = System.Diagnostics.Process.Start(psi))
- {
- if (shell && args != null)
- await p.StandardInput.WriteLineAsync(args);
-
- var res = p.StandardOutput.ReadToEndAsync();
+ }
+
+ /// <summary>
+ /// Runs an external command
+ /// </summary>
+ /// <returns>The stdout data.</returns>
+ /// <param name="command">The executable</param>
+ /// <param name="args">The executable and the arguments.</param>
+ /// <param name="shell">If set to <c>true</c> use the shell context for execution.</param>
+ /// <param name="exitcode">Set the value to check for a particular exitcode.</param>
+ private static async Task<string> ShellExec(string command, string args = null, bool shell = false, int exitcode = -1, Dictionary<string, string> env = null)
+ {
+ var psi = new ProcessStartInfo()
+ {
+ FileName = command,
+ Arguments = shell ? null : args,
+ UseShellExecute = false,
+ RedirectStandardInput = shell,
+ RedirectStandardOutput = true
+ };
+
+ if (env != null)
+ foreach (var pk in env)
+ psi.EnvironmentVariables[pk.Key] = pk.Value;
+
+ using (var p = System.Diagnostics.Process.Start(psi))
+ {
+ if (shell && args != null)
+ await p.StandardInput.WriteLineAsync(args);
+
+ var res = p.StandardOutput.ReadToEndAsync();
var tries = 10;
var ms = (int)TimeSpan.FromSeconds(0.5).TotalMilliseconds;
@@ -261,28 +261,28 @@ namespace Duplicati.Server.WebServer
{
tries--;
p.WaitForExit(ms);
- }
-
- if (!p.HasExited)
+ }
+
+ if (!p.HasExited)
try { p.Kill(); }
catch { }
- if (!p.HasExited || (p.ExitCode != exitcode && exitcode != -1))
- throw new Exception(string.Format("Exit code was: {0}, stdout: {1}", p.ExitCode, res));
- return await res;
- }
- }
-
- /// <summary>
- /// Gets the environment variable argument.
- /// </summary>
- /// <returns>The environment variable.</returns>
- /// <param name="key">The name of the environment variable.</param>
- /// <param name="default">The default value.</param>
- private static string GetEnvArg(string key, string @default = null)
- {
- var res = Environment.GetEnvironmentVariable(key);
- return string.IsNullOrWhiteSpace(res) ? @default : res.Trim();
- }
- }
-}
+ if (!p.HasExited || (p.ExitCode != exitcode && exitcode != -1))
+ throw new Exception(string.Format("Exit code was: {0}, stdout: {1}", p.ExitCode, res));
+ return await res;
+ }
+ }
+
+ /// <summary>
+ /// Gets the environment variable argument.
+ /// </summary>
+ /// <returns>The environment variable.</returns>
+ /// <param name="key">The name of the environment variable.</param>
+ /// <param name="default">The default value.</param>
+ private static string GetEnvArg(string key, string @default = null)
+ {
+ var res = Environment.GetEnvironmentVariable(key);
+ return string.IsNullOrWhiteSpace(res) ? @default : res.Trim();
+ }
+ }
+}
diff --git a/Duplicati/UnitTest/BasicSetupHelper.cs b/Duplicati/UnitTest/BasicSetupHelper.cs
index eb2128858..ce045a3da 100644
--- a/Duplicati/UnitTest/BasicSetupHelper.cs
+++ b/Duplicati/UnitTest/BasicSetupHelper.cs
@@ -62,7 +62,7 @@ namespace Duplicati.UnitTest
/// </summary>
public static readonly bool DEBUG_OUTPUT =
new[] { "1", "true", "on", "yes" }
- .Contains(Environment.GetEnvironmentVariable("DEBUG_OUTPUT") ?? "", StringComparer.InvariantCultureIgnoreCase);
+ .Contains(Environment.GetEnvironmentVariable("DEBUG_OUTPUT") ?? "", StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Writes a message to TestContext.Progress and Console.Out