From 457254d9e1b7af7fd1829f289150e302fe6d783e Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Tue, 16 Apr 2019 21:35:02 -0700 Subject: [PATCH] Remove unused local variables. --- Duplicati/CommandLine/Commands.cs | 3 +-- Duplicati/CommandLine/RecoveryTool/List.cs | 3 +-- Duplicati/CommandLine/RecoveryTool/Restore.cs | 2 -- Duplicati/Library/Backend/File/FileBackend.cs | 3 +-- Duplicati/Library/Main/Controller.cs | 6 ++---- .../Library/Main/Database/HashLookupHelper.cs | 5 ++--- Duplicati/Library/Main/Operation/CompactHandler.cs | 7 ------- Duplicati/Library/Modules/Builtin/HyperVOptions.cs | 5 +---- Duplicati/Library/Modules/Builtin/MSSQLOptions.cs | 5 +---- Duplicati/Library/Utility/FilterExpression.cs | 3 +-- Duplicati/Server/Database/Schedule.cs | 5 ++--- .../Server/WebServer/AuthenticationHandler.cs | 14 +++++--------- Duplicati/Server/WebServer/Server.cs | 3 +-- 13 files changed, 18 insertions(+), 46 deletions(-) diff --git a/Duplicati/CommandLine/Commands.cs b/Duplicati/CommandLine/Commands.cs index fcd971add..ba26a4948 100644 --- a/Duplicati/CommandLine/Commands.cs +++ b/Duplicati/CommandLine/Commands.cs @@ -69,14 +69,13 @@ namespace Duplicati.CommandLine while (true) { - Duplicati.Library.Main.OperationPhase phase; float progress; long filesprocessed; long filesizeprocessed; long filecount; long filesize; bool counting; - m_output.OperationProgress.UpdateOverall(out phase, out progress, out filesprocessed, out filesizeprocessed, out filecount, out filesize, out counting); + m_output.OperationProgress.UpdateOverall(out _, out progress, out filesprocessed, out filesizeprocessed, out filecount, out filesize, out counting); var files = Math.Max(0, filecount - filesprocessed); var size = Math.Max(0, filesize - filesizeprocessed); diff --git a/Duplicati/CommandLine/RecoveryTool/List.cs b/Duplicati/CommandLine/RecoveryTool/List.cs index a29db35dd..346e5e765 100644 --- a/Duplicati/CommandLine/RecoveryTool/List.cs +++ b/Duplicati/CommandLine/RecoveryTool/List.cs @@ -74,8 +74,7 @@ namespace Duplicati.CommandLine.RecoveryTool continue; bool result; - Library.Utility.IFilter evfilter; - bool match = filter.Matches(f.Path, out result, out evfilter); + bool match = filter.Matches(f.Path, out result, out _); if (!match || result) yield return f; } diff --git a/Duplicati/CommandLine/RecoveryTool/Restore.cs b/Duplicati/CommandLine/RecoveryTool/Restore.cs index 73d999c68..734565b5b 100644 --- a/Duplicati/CommandLine/RecoveryTool/Restore.cs +++ b/Duplicati/CommandLine/RecoveryTool/Restore.cs @@ -156,7 +156,6 @@ namespace Duplicati.CommandLine.RecoveryTool Console.WriteLine("Removing common prefix {0} from files", largestprefix); var i = 0L; - var errors = 0L; foreach (var f in List.EnumerateFilesInDList(filelist, filter, options)) { try @@ -236,7 +235,6 @@ namespace Duplicati.CommandLine.RecoveryTool catch (Exception ex) { Console.WriteLine(" error: {0}", ex); - errors++; } i++; } diff --git a/Duplicati/Library/Backend/File/FileBackend.cs b/Duplicati/Library/Backend/File/FileBackend.cs index 07f3510f2..a0fa50111 100644 --- a/Duplicati/Library/Backend/File/FileBackend.cs +++ b/Duplicati/Library/Backend/File/FileBackend.cs @@ -374,8 +374,7 @@ namespace Duplicati.Library.Backend { ulong available; ulong total; - ulong free; - if (WindowsDriveHelper.GetDiskFreeSpaceEx(directory, out available, out total, out free)) + if (WindowsDriveHelper.GetDiskFreeSpaceEx(directory, out available, out total, out _)) { return new QuotaInfo((long)total, (long)available); } diff --git a/Duplicati/Library/Main/Controller.cs b/Duplicati/Library/Main/Controller.cs index 2503faf55..81747ea74 100644 --- a/Duplicati/Library/Main/Controller.cs +++ b/Duplicati/Library/Main/Controller.cs @@ -935,10 +935,9 @@ namespace Duplicati.Library.Main { if (filter != null) { - bool includes; bool excludes; - FilterExpression.AnalyzeFilters(filter, out includes, out excludes); + FilterExpression.AnalyzeFilters(filter, out _, out excludes); // If there are no excludes, there is no need to keep the folder as a filter if (excludes) @@ -1012,8 +1011,7 @@ namespace Duplicati.Library.Main } else if (arg.Type == Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Integer) { - long l; - if (!long.TryParse(value, out l)) + if (!long.TryParse(value, out _)) return Strings.Controller.UnsupportedIntegerValue(optionname, value); } else if (arg.Type == Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Path) diff --git a/Duplicati/Library/Main/Database/HashLookupHelper.cs b/Duplicati/Library/Main/Database/HashLookupHelper.cs index 679781a4e..ddcf8482e 100644 --- a/Duplicati/Library/Main/Database/HashLookupHelper.cs +++ b/Duplicati/Library/Main/Database/HashLookupHelper.cs @@ -57,9 +57,8 @@ namespace Duplicati.Library.Main var lst = m_lookup[key]; if (lst == null) lst = m_lookup[key] = new SortedList(1); - - T tmp; - if (!lst.TryGetValue(hash + ':' + size.ToString(), out tmp)) + + if (!lst.TryGetValue(hash + ':' + size.ToString(), out _)) { lst.Add(hash + ':' + size.ToString(), value); return true; diff --git a/Duplicati/Library/Main/Operation/CompactHandler.cs b/Duplicati/Library/Main/Operation/CompactHandler.cs index 1197f4344..297acb129 100644 --- a/Duplicati/Library/Main/Operation/CompactHandler.cs +++ b/Duplicati/Library/Main/Operation/CompactHandler.cs @@ -113,8 +113,6 @@ namespace Duplicati.Library.Main.Operation } long blocksInVolume = 0; - long discardedBlocks = 0; - long discardedSize = 0; byte[] buffer = new byte[m_options.Blocksize]; var remoteList = db.GetRemoteVolumes().Where(n => n.State == RemoteVolumeState.Uploaded || n.State == RemoteVolumeState.Verified).ToArray(); @@ -203,11 +201,6 @@ namespace Duplicati.Library.Main.Operation deleteableVolumes = new List(); } } - else - { - discardedBlocks++; - discardedSize += e.Value; - } } } diff --git a/Duplicati/Library/Modules/Builtin/HyperVOptions.cs b/Duplicati/Library/Modules/Builtin/HyperVOptions.cs index e56130d4f..af2a6f354 100644 --- a/Duplicati/Library/Modules/Builtin/HyperVOptions.cs +++ b/Duplicati/Library/Modules/Builtin/HyperVOptions.cs @@ -197,10 +197,7 @@ namespace Duplicati.Library.Modules.Builtin foreach (var guestForBackup in guestsForBackup) foreach (var pathForBackup in guestForBackup.DataPaths) { - bool bResult; - Utility.IFilter matchFilter; - - if (!filterhandler.Matches(pathForBackup, out bResult, out matchFilter)) + if (!filterhandler.Matches(pathForBackup, out _, out _)) { Logging.Log.WriteInformationMessage(LOGTAG, "IncludeHyperV", "For VM {0} - adding {1}", guestForBackup.Name, pathForBackup); pathsForBackup.Add(pathForBackup); diff --git a/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs b/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs index 6bdb1a072..13c8decfa 100644 --- a/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs +++ b/Duplicati/Library/Modules/Builtin/MSSQLOptions.cs @@ -195,10 +195,7 @@ namespace Duplicati.Library.Modules.Builtin foreach (var dbForBackup in dbsForBackup) foreach (var pathForBackup in dbForBackup.DataPaths) { - bool bResult; - Utility.IFilter matchFilter; - - if (!filterhandler.Matches(pathForBackup, out bResult, out matchFilter)) + if (!filterhandler.Matches(pathForBackup, out _, out _)) { Logging.Log.WriteInformationMessage(LOGTAG, "IncludeDatabase", "For DB {0} - adding {1}", dbForBackup.Name, pathForBackup); pathsForBackup.Add(pathForBackup); diff --git a/Duplicati/Library/Utility/FilterExpression.cs b/Duplicati/Library/Utility/FilterExpression.cs index 48ab1f93e..7dd46155f 100644 --- a/Duplicati/Library/Utility/FilterExpression.cs +++ b/Duplicati/Library/Utility/FilterExpression.cs @@ -483,8 +483,7 @@ namespace Duplicati.Library.Utility /// The path to evaluate public static bool Matches(IFilter filter, string path) { - IFilter match; - return Matches(filter, path, out match); + return Matches(filter, path, out _); } /// diff --git a/Duplicati/Server/Database/Schedule.cs b/Duplicati/Server/Database/Schedule.cs index 417b0668f..7df817d40 100644 --- a/Duplicati/Server/Database/Schedule.cs +++ b/Duplicati/Server/Database/Schedule.cs @@ -45,10 +45,9 @@ namespace Duplicati.Server.Database if (days == null) return null; - - DayOfWeek dw = DayOfWeek.Monday; + return (from n in days - where Enum.TryParse(n, true, out dw) + where Enum.TryParse(n, true, out _) select (DayOfWeek)Enum.Parse(typeof(DayOfWeek), n, true)) .ToArray(); } diff --git a/Duplicati/Server/WebServer/AuthenticationHandler.cs b/Duplicati/Server/WebServer/AuthenticationHandler.cs index 5558c95e5..42537f501 100644 --- a/Duplicati/Server/WebServer/AuthenticationHandler.cs +++ b/Duplicati/Server/WebServer/AuthenticationHandler.cs @@ -104,11 +104,9 @@ namespace Duplicati.Server.WebServer private bool HasXSRFCookie(HttpServer.IHttpRequest request) { - DateTime tmpExpirationTimeHolder; - // Clean up expired XSRF cookies foreach (var k in (from n in m_activexsrf where DateTime.UtcNow > n.Value select n.Key)) - m_activexsrf.TryRemove(k, out tmpExpirationTimeHolder); + m_activexsrf.TryRemove(k, out _); var xsrfcookie = request.Cookies[XSRF_COOKIE_NAME] ?? request.Cookies[Library.Utility.Uri.UrlEncode(XSRF_COOKIE_NAME)]; var value = xsrfcookie == null ? null : xsrfcookie.Value; @@ -147,15 +145,13 @@ namespace Duplicati.Server.WebServer return true; } } - Tuple tmpTuple; - DateTime tmpDateTime; if (LOGOUT_SCRIPT_URI.Equals(request.Uri.AbsolutePath, StringComparison.OrdinalIgnoreCase)) { if (!string.IsNullOrWhiteSpace(auth_token)) { // Remove the active auth token - m_activeTokens.TryRemove(auth_token, out tmpDateTime); + m_activeTokens.TryRemove(auth_token, out _); } response.Status = System.Net.HttpStatusCode.NoContent; @@ -167,7 +163,7 @@ namespace Duplicati.Server.WebServer { // Remove expired nonces foreach(var k in (from n in m_activeNonces where DateTime.UtcNow > n.Value.Item1 select n.Key)) - m_activeNonces.TryRemove(k, out tmpTuple); + m_activeNonces.TryRemove(k, out _); if (input["get-nonce"] != null && !string.IsNullOrWhiteSpace(input["get-nonce"].Value)) { @@ -233,7 +229,7 @@ namespace Duplicati.Server.WebServer var pwd = m_activeNonces[nonce].Item2; // Remove the nonce - m_activeNonces.TryRemove(nonce, out tmpTuple); + m_activeNonces.TryRemove(nonce, out _); if (pwd != input["password"].Value) { @@ -296,7 +292,7 @@ namespace Duplicati.Server.WebServer return false; foreach(var k in (from n in m_activeTokens where DateTime.UtcNow > n.Value select n.Key)) - m_activeTokens.TryRemove(k, out tmpDateTime); + m_activeTokens.TryRemove(k, out _); // If we have a valid token, proceed diff --git a/Duplicati/Server/WebServer/Server.cs b/Duplicati/Server/WebServer/Server.cs index efa46c538..0bb2138f4 100644 --- a/Duplicati/Server/WebServer/Server.cs +++ b/Duplicati/Server/WebServer/Server.cs @@ -75,14 +75,13 @@ namespace Duplicati.Server.WebServer /// A set of options public Server(IDictionary options) { - int port; string portstring; IEnumerable ports = null; options.TryGetValue(OPTION_PORT, out portstring); if (!string.IsNullOrEmpty(portstring)) ports = from n in portstring.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) - where int.TryParse(n, out port) + where int.TryParse(n, out _) select int.Parse(n); if (ports == null || !ports.Any())