Remove unused variables and fields.
This commit is contained in:
@@ -27,12 +27,6 @@ namespace Duplicati.CommandLine.BackendTester
|
||||
{
|
||||
class Program
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Used to maintain a reference to initialized system settings.
|
||||
/// </summary>
|
||||
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");
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<DriveItem>(response);
|
||||
this.ParseResponse<DriveItem>(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<UploadSession>(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<UploadSession>(response);
|
||||
this.ParseResponse<UploadSession>(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<DriveItem>(rootPath);
|
||||
this.Get<DriveItem>(rootPath);
|
||||
}
|
||||
catch (DriveItemNotFoundException ex)
|
||||
{
|
||||
|
||||
@@ -248,7 +248,6 @@ namespace Duplicati.Library.Main
|
||||
private readonly LocalDatabase m_database;
|
||||
private readonly System.Threading.Thread m_callerThread;
|
||||
private List<IDbEntry> 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<IDbEntry>();
|
||||
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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -159,9 +159,6 @@ namespace Duplicati.Library.Modules.Builtin
|
||||
/// </summary>
|
||||
private bool m_isConfigured;
|
||||
/// <summary>
|
||||
/// A value indicating if this instance has been disposed
|
||||
/// </summary>
|
||||
private bool m_isDisposed;
|
||||
/// <summary>
|
||||
/// The mail subject
|
||||
/// </summary>
|
||||
|
||||
@@ -399,12 +399,6 @@ namespace Duplicati.Library.Utility
|
||||
/// </summary>
|
||||
public class DataPump
|
||||
{
|
||||
/// <summary> Minimum buffer size for pumping </summary>
|
||||
public const int MINBUFSIZE = 1 << 10; // 1K
|
||||
/// <summary> Default buffer size for pumping </summary>
|
||||
public const int DEFAULTBUFSIZE = 1 << 14; // 16K
|
||||
|
||||
private readonly int m_bufsize;
|
||||
private readonly bool m_closeInputWhenDone, m_closeOutputWhenDone;
|
||||
private readonly Action<DataPump> m_callbackFinalizePumping = null;
|
||||
private Stream m_input, m_output;
|
||||
@@ -415,17 +409,15 @@ namespace Duplicati.Library.Utility
|
||||
/// <summary> Creates and configures a new DataPump instance. </summary>
|
||||
/// <param name="input"> The stream to read data from. </param>
|
||||
/// <param name="output"> The stream to write data to. </param>
|
||||
/// <param name="bufsize"> The internal buffer size for reading/writing. </param>
|
||||
/// <param name="callbackFinalizePumping"> A callback to issue when pumping is done but before streams are closed. e.g. Can add data to output. </param>
|
||||
/// <param name="dontCloseInputWhenDone"> Disable auto close of input stream when pumping is done. </param>
|
||||
/// <param name="dontCloseOutputWhenDone"> Disable auto close of output stream when pumping is done. </param>
|
||||
public DataPump(Stream input, Stream output, int bufsize = DEFAULTBUFSIZE
|
||||
public DataPump(Stream input, Stream output
|
||||
, Action<DataPump> 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
|
||||
/// <summary> Actually transfers stream data. </summary>
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,11 +133,6 @@ namespace Duplicati.Server
|
||||
|
||||
private static System.Threading.Timer PurgeTempFilesTimer = null;
|
||||
|
||||
/// <summary>
|
||||
/// Used to maintain a reference to initialized system settings.
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user