diff --git a/Duplicati/CommandLine/BackendTester/Program.cs b/Duplicati/CommandLine/BackendTester/Program.cs index 555f8c38a..b7988373a 100644 --- a/Duplicati/CommandLine/BackendTester/Program.cs +++ b/Duplicati/CommandLine/BackendTester/Program.cs @@ -27,12 +27,6 @@ namespace Duplicati.CommandLine.BackendTester { class Program { - - /// - /// Used to maintain a reference to initialized system settings. - /// - private static IDisposable SystemSettings; - class TempFile { public readonly string remotefilename; @@ -107,8 +101,6 @@ namespace Duplicati.CommandLine.BackendTester if (options.ContainsKey("tempdir") && !string.IsNullOrEmpty(options["tempdir"])) Library.Utility.SystemContextSettings.DefaultTempPath = options["tempdir"]; - SystemSettings = Duplicati.Library.Utility.SystemContextSettings.StartSession(); - if (!options.ContainsKey("auth_password") && !string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("AUTH_PASSWORD"))) options["auth_password"] = System.Environment.GetEnvironmentVariable("AUTH_PASSWORD"); diff --git a/Duplicati/CommandLine/Commands.cs b/Duplicati/CommandLine/Commands.cs index 5ffbfb139..a25f55000 100644 --- a/Duplicati/CommandLine/Commands.cs +++ b/Duplicati/CommandLine/Commands.cs @@ -1052,7 +1052,7 @@ namespace Duplicati.CommandLine using (var i = new Library.Main.Controller(args[0], options, console)) { setup(i); - var res = i.PurgeBrokenFiles(filter); + i.PurgeBrokenFiles(filter); } return 0; diff --git a/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs b/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs index ebf9a92a6..4f4af9475 100644 --- a/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs +++ b/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs @@ -341,7 +341,7 @@ namespace Duplicati.Library.Backend var response = this.m_client.PutAsync(string.Format("{0}/root:{1}{2}:/content", this.DrivePrefix, this.m_path, NormalizeSlashes(remotename)), streamContent).Await(); // Make sure this response is a valid drive item, though we don't actually use it for anything currently. - var result = this.ParseResponse(response); + this.ParseResponse(response); } else { @@ -353,7 +353,7 @@ namespace Duplicati.Library.Backend HttpRequestMessage createSessionRequest = new HttpRequestMessage(HttpMethod.Post, string.Format("{0}/root:{1}{2}:/createUploadSession", this.DrivePrefix, this.m_path, NormalizeSlashes(remotename))); // Indicate that we want to replace any existing content with this new data we're uploading - StringContent createSessionContent = this.PrepareContent(new UploadSession() { Item = new DriveItem() { ConflictBehavior = ConflictBehavior.Replace } }); + this.PrepareContent(new UploadSession() { Item = new DriveItem() { ConflictBehavior = ConflictBehavior.Replace } }); HttpResponseMessage createSessionResponse = this.m_client.SendAsync(createSessionRequest).Await(); UploadSession uploadSession = this.ParseResponse(createSessionResponse); @@ -384,7 +384,7 @@ namespace Duplicati.Library.Backend response = this.m_client.SendAsync(request, false).Await(); // Note: On the last request, the json result includes the default properties of the item that was uploaded - var result = this.ParseResponse(response); + this.ParseResponse(response); } catch (MicrosoftGraphException ex) { @@ -446,7 +446,7 @@ namespace Duplicati.Library.Backend try { string rootPath = string.Format("{0}/root:{1}", this.DrivePrefix, this.m_path); - DriveItem rootFolder = this.Get(rootPath); + this.Get(rootPath); } catch (DriveItemNotFoundException ex) { diff --git a/Duplicati/Library/Main/BackendManager.cs b/Duplicati/Library/Main/BackendManager.cs index 64f302fc4..9c628b340 100644 --- a/Duplicati/Library/Main/BackendManager.cs +++ b/Duplicati/Library/Main/BackendManager.cs @@ -248,7 +248,6 @@ namespace Duplicati.Library.Main private readonly LocalDatabase m_database; private readonly System.Threading.Thread m_callerThread; private List m_dbqueue; - private readonly IBackendWriter m_stats; private interface IDbEntry { } @@ -273,10 +272,9 @@ namespace Duplicati.Library.Main public string Newname; } - public DatabaseCollector(LocalDatabase database, IBackendWriter stats) + public DatabaseCollector(LocalDatabase database) { m_database = database; - m_stats = stats; m_dbqueue = new List(); if (m_database != null) m_callerThread = System.Threading.Thread.CurrentThread; @@ -378,7 +376,7 @@ namespace Duplicati.Library.Main m_numberofretries = options.NumberOfRetries; m_retrydelay = options.RetryDelay; - m_db = new DatabaseCollector(database, statwriter); + m_db = new DatabaseCollector(database); m_backend = DynamicLoader.BackendLoader.GetBackend(m_backendurl, m_options.RawOptions); if (m_backend == null) diff --git a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs index 3c657ffff..f43168504 100644 --- a/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs +++ b/Duplicati/Library/Main/Database/LocalRestoreDatabase.cs @@ -100,7 +100,7 @@ namespace Duplicati.Library.Main.Database , m_fileprogtable, m_tempfiletable, m_tempblocktable); // Will be one row per file. - int fileCnt = cmd.ExecuteNonQuery(sql); + cmd.ExecuteNonQuery(sql); sql = string.Format( @"INSERT INTO ""{0}"" (" @@ -115,7 +115,7 @@ namespace Duplicati.Library.Main.Database , m_totalprogtable, m_fileprogtable); // Will result in a single line (no support to also track metadata) - int totalStatRowCount = cmd.ExecuteNonQuery(sql); + cmd.ExecuteNonQuery(sql); // Finally we create TRIGGERs to keep all our statistics up to date. // This is lightning fast, as SQLite uses internal hooks and our indices to do the update magic. diff --git a/Duplicati/Library/Main/Operation/Backup/StreamBlockSplitter.cs b/Duplicati/Library/Main/Operation/Backup/StreamBlockSplitter.cs index 164a044a1..b96d9286f 100644 --- a/Duplicati/Library/Main/Operation/Backup/StreamBlockSplitter.cs +++ b/Duplicati/Library/Main/Operation/Backup/StreamBlockSplitter.cs @@ -67,7 +67,6 @@ namespace Duplicati.Library.Main.Operation.Backup { var send_close = false; var filesize = 0L; - var filename = string.Empty; var e = await self.Input.ReadAsync(); var cur = e.Result; diff --git a/Duplicati/Library/Main/Operation/RestoreHandler.cs b/Duplicati/Library/Main/Operation/RestoreHandler.cs index 073c09c58..eb0a0923b 100644 --- a/Duplicati/Library/Main/Operation/RestoreHandler.cs +++ b/Duplicati/Library/Main/Operation/RestoreHandler.cs @@ -114,71 +114,13 @@ namespace Duplicati.Library.Main.Operation { using(var metadatastorage = new RestoreHandlerMetadataStorage()) { - System.Security.Cryptography.HashAlgorithm blockhasher = null; - System.Security.Cryptography.HashAlgorithm filehasher = null; - - bool first = true; - RecreateDatabaseHandler.BlockVolumePostProcessor localpatcher = - (key, rd) => - { - if (first) - { - Utility.UpdateOptionsFromDb(database, m_options); - m_blockbuffer = new byte[m_options.Blocksize]; - - //Figure out what files are to be patched, and what blocks are needed - PrepareBlockAndFileList(database, m_options, filter, m_result); - - blockhasher = Library.Utility.HashAlgorithmHelper.Create(m_options.BlockHashAlgorithm); - filehasher = Library.Utility.HashAlgorithmHelper.Create(m_options.FileHashAlgorithm); - if (blockhasher == null) - throw new UserInformationException(Strings.Common.InvalidHashAlgorithm(m_options.BlockHashAlgorithm), "BlockHashAlgorithmNotSupported"); - if (!blockhasher.CanReuseTransform) - throw new UserInformationException(Strings.Common.InvalidCryptoSystem(m_options.BlockHashAlgorithm), "BlockHashAlgorithmNotSupported"); - - if (filehasher == null) - throw new UserInformationException(Strings.Common.InvalidHashAlgorithm(m_options.FileHashAlgorithm), "FileHashAlgorithmNotSupported"); - if (!filehasher.CanReuseTransform) - throw new UserInformationException(Strings.Common.InvalidCryptoSystem(m_options.FileHashAlgorithm), "FileHashAlgorithmNotSupported"); - - // Don't run this again - first = false; - } - else - { - // Patch the missing blocks list to include the newly discovered blocklists - //UpdateMissingBlocksTable(key); - } - - if (m_result.TaskControlRendevouz() == TaskControlState.Stop) - return; - - CreateDirectoryStructure(database, m_options, m_result); - - //If we are patching an existing target folder, do not touch stuff that is already updated - ScanForExistingTargetBlocks(database, m_blockbuffer, blockhasher, filehasher, m_options, m_result); - - if (m_result.TaskControlRendevouz() == TaskControlState.Stop) - return; - - // If other local files already have the blocks we want, we use them instead of downloading - if (!m_options.NoLocalBlocks) - ScanForExistingSourceBlocks(database, m_options, m_blockbuffer, blockhasher, m_result, metadatastorage); - - if (m_result.TaskControlRendevouz() == TaskControlState.Stop) - return; - - //Update files with data - PatchWithBlocklist(database, rd, m_options, m_result, m_blockbuffer, metadatastorage); - }; - // TODO: When UpdateMissingBlocksTable is implemented, the localpatcher can be activated // and this will reduce the need for multiple downloads of the same volume // TODO: This will need some work to preserve the missing block list for use with --fh-dryrun m_result.RecreateDatabaseResults = new RecreateDatabaseResults(m_result); using(new Logging.Timer(LOGTAG, "RecreateTempDbForRestore", "Recreate temporary database for restore")) new RecreateDatabaseHandler(m_backendurl, m_options, (RecreateDatabaseResults)m_result.RecreateDatabaseResults) - .DoRun(database, false, filter, filelistfilter, /*localpatcher*/null); + .DoRun(database, false, filter, filelistfilter, null); if (!m_options.SkipMetadata) ApplyStoredMetadata(database, m_options, m_result, metadatastorage); diff --git a/Duplicati/Library/Main/Operation/TestFilterHandler.cs b/Duplicati/Library/Main/Operation/TestFilterHandler.cs index d0356332f..e3d58ec9c 100644 --- a/Duplicati/Library/Main/Operation/TestFilterHandler.cs +++ b/Duplicati/Library/Main/Operation/TestFilterHandler.cs @@ -42,7 +42,6 @@ namespace Duplicati.Library.Main.Operation public void Run(string[] sources, Library.Utility.IFilter filter) { - var storeSymlinks = m_options.SymlinkPolicy == Options.SymlinkStrategy.Store; var sourcefilter = new Library.Utility.FilterExpression(sources, true); using(var snapshot = BackupHandler.GetSnapshot(sources, m_options)) diff --git a/Duplicati/Library/Modules/Builtin/ReportHelper.cs b/Duplicati/Library/Modules/Builtin/ReportHelper.cs index 4f5f145c3..397ee4f7e 100644 --- a/Duplicati/Library/Modules/Builtin/ReportHelper.cs +++ b/Duplicati/Library/Modules/Builtin/ReportHelper.cs @@ -159,9 +159,6 @@ namespace Duplicati.Library.Modules.Builtin /// private bool m_isConfigured; /// - /// A value indicating if this instance has been disposed - /// - private bool m_isDisposed; /// /// The mail subject /// diff --git a/Duplicati/Library/Utility/DirectStreamLink.cs b/Duplicati/Library/Utility/DirectStreamLink.cs index 43c06839b..89e330463 100644 --- a/Duplicati/Library/Utility/DirectStreamLink.cs +++ b/Duplicati/Library/Utility/DirectStreamLink.cs @@ -399,12 +399,6 @@ namespace Duplicati.Library.Utility /// public class DataPump { - /// Minimum buffer size for pumping - public const int MINBUFSIZE = 1 << 10; // 1K - /// Default buffer size for pumping - public const int DEFAULTBUFSIZE = 1 << 14; // 16K - - private readonly int m_bufsize; private readonly bool m_closeInputWhenDone, m_closeOutputWhenDone; private readonly Action m_callbackFinalizePumping = null; private Stream m_input, m_output; @@ -415,17 +409,15 @@ namespace Duplicati.Library.Utility /// Creates and configures a new DataPump instance. /// The stream to read data from. /// The stream to write data to. - /// The internal buffer size for reading/writing. /// A callback to issue when pumping is done but before streams are closed. e.g. Can add data to output. /// Disable auto close of input stream when pumping is done. /// Disable auto close of output stream when pumping is done. - public DataPump(Stream input, Stream output, int bufsize = DEFAULTBUFSIZE + public DataPump(Stream input, Stream output , Action callbackFinalizePumping = null , bool dontCloseInputWhenDone = false, bool dontCloseOutputWhenDone = false) { this.m_input = input; this.m_output = output; - this.m_bufsize = Math.Max(MINBUFSIZE, bufsize); this.m_callbackFinalizePumping = callbackFinalizePumping; this.m_closeInputWhenDone = !dontCloseInputWhenDone; this.m_closeOutputWhenDone = !dontCloseOutputWhenDone; @@ -453,7 +445,6 @@ namespace Duplicati.Library.Utility /// Actually transfers stream data. private long doRun(bool rethrowException) { - Exception hadException = null; byte[] buf = new byte[1 << 14]; int c; try { @@ -469,9 +460,8 @@ namespace Duplicati.Library.Utility catch { } } } - catch (Exception ex) + catch (Exception) { - hadException = ex; if (rethrowException) throw; } finally diff --git a/Duplicati/Library/Utility/SslCertificateValidator.cs b/Duplicati/Library/Utility/SslCertificateValidator.cs index 658d731aa..f5319ff57 100644 --- a/Duplicati/Library/Utility/SslCertificateValidator.cs +++ b/Duplicati/Library/Utility/SslCertificateValidator.cs @@ -52,7 +52,6 @@ namespace Duplicati.Library.Utility private readonly bool m_acceptAll = false; private readonly string[] m_validHashes = null; - private Exception m_uncastException = null; public bool ValidateServerCertficate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslPolicyErrors) { @@ -79,7 +78,6 @@ namespace Duplicati.Library.Utility throw new Exception(Strings.SslCertificateValidator.VerifyCertificateHashError(ex, sslPolicyErrors), ex); } - m_uncastException = new InvalidCertificateException(certHash, sslPolicyErrors); return false; } } diff --git a/Duplicati/Server/Program.cs b/Duplicati/Server/Program.cs index 3fabecef6..bee34dca1 100644 --- a/Duplicati/Server/Program.cs +++ b/Duplicati/Server/Program.cs @@ -133,11 +133,6 @@ namespace Duplicati.Server private static System.Threading.Timer PurgeTempFilesTimer = null; - /// - /// Used to maintain a reference to initialized system settings. - /// - private static IDisposable SystemSettings; - public static int ServerPort { get @@ -209,7 +204,7 @@ namespace Duplicati.Server if (commandlineOptions.ContainsKey("tempdir") && !string.IsNullOrEmpty(commandlineOptions["tempdir"])) Library.Utility.SystemContextSettings.DefaultTempPath = commandlineOptions["tempdir"]; - SystemSettings = Duplicati.Library.Utility.SystemContextSettings.StartSession(); + Library.Utility.SystemContextSettings.StartSession(); // Check if a parameters-file was provided. Skip if help was already specified if (!commandlineOptions.ContainsKey("help")) @@ -255,9 +250,6 @@ namespace Duplicati.Server try { - // Setup the log redirect - var logscope = Library.Logging.Log.StartScope(Program.LogHandler, null); - if (commandlineOptions.ContainsKey("log-file")) { #if DEBUG diff --git a/Duplicati/UnitTest/BorderTests.cs b/Duplicati/UnitTest/BorderTests.cs index f662c83a9..2cc0630d0 100644 --- a/Duplicati/UnitTest/BorderTests.cs +++ b/Duplicati/UnitTest/BorderTests.cs @@ -234,7 +234,7 @@ namespace Duplicati.UnitTest using(var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts.Expand(new { version = 0 }), null)) { - var r = c.List("*"); + c.List("*"); //Console.WriteLine("In first backup:"); //Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path))); } diff --git a/Duplicati/UnitTest/PurgeTesting.cs b/Duplicati/UnitTest/PurgeTesting.cs index ac4387b94..de87d72e7 100644 --- a/Duplicati/UnitTest/PurgeTesting.cs +++ b/Duplicati/UnitTest/PurgeTesting.cs @@ -175,7 +175,6 @@ namespace Duplicati.UnitTest var round1 = filenames.Take(filenames.Count / 3).ToArray(); var round2 = filenames.Take((filenames.Count / 3) * 2).ToArray(); - var round3 = filenames; using (var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts, null)) {