diff options
author | Tyler Gill <tyler.gill@byu.net> | 2017-09-19 08:23:45 +0300 |
---|---|---|
committer | Tyler Gill <tyler.gill@byu.net> | 2017-09-19 08:55:08 +0300 |
commit | 83a1dcfb64104b51e09f17dcf9237a184f7086aa (patch) | |
tree | dbe324fbfeb569b7444edef0c031dc40e9abe85d /Duplicati/Library | |
parent | 3e0aa28c29b2532d679a5d2f946e31bab5e9bde4 (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)
Diffstat (limited to 'Duplicati/Library')
34 files changed, 203 insertions, 203 deletions
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)
|