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

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Skovhede <kenneth@hexad.dk>2022-06-14 23:44:15 +0300
committerKenneth Skovhede <kenneth@hexad.dk>2022-06-14 23:44:15 +0300
commitb4eeb4542b3fc48b9cd5e22866cfe05e2d9c776a (patch)
treed88618530616bb0c01a3f2f42230837fbfe9bd8b
parent1128de1cc6f9595f45d55a153634641899408e16 (diff)
Added checks to re-enable `--use-move-for-put`.feature/fix-move-for-put
This fixes #4745
-rw-r--r--Duplicati/Library/Backend/File/FileBackend.cs19
-rw-r--r--Duplicati/Library/Backend/File/Strings.cs2
2 files changed, 17 insertions, 4 deletions
diff --git a/Duplicati/Library/Backend/File/FileBackend.cs b/Duplicati/Library/Backend/File/FileBackend.cs
index 4da500458..a2b005458 100644
--- a/Duplicati/Library/Backend/File/FileBackend.cs
+++ b/Duplicati/Library/Backend/File/FileBackend.cs
@@ -37,6 +37,7 @@ namespace Duplicati.Library.Backend
private const string OPTION_ALTERNATE_PATHS = "alternate-target-paths";
private const string OPTION_MOVE_FILE = "use-move-for-put";
private const string OPTION_FORCE_REAUTH = "force-smb-authentication";
+ private const string OPTION_DISABLE_LENGTH_VERIFICATION = "disable-length-verification";
private readonly string m_path;
private string m_username;
@@ -44,6 +45,7 @@ namespace Duplicati.Library.Backend
private readonly bool m_moveFile;
private bool m_hasAutenticated;
private readonly bool m_forceReauth;
+ private readonly bool m_verifyDestinationLength;
private readonly byte[] m_copybuffer = new byte[Utility.Utility.DEFAULT_BUFFER_SIZE];
@@ -127,6 +129,7 @@ namespace Duplicati.Library.Backend
m_moveFile = Utility.Utility.ParseBoolOption(options, OPTION_MOVE_FILE);
m_forceReauth = Utility.Utility.ParseBoolOption(options, OPTION_FORCE_REAUTH);
+ m_verifyDestinationLength = Utility.Utility.ParseBoolOption(options, OPTION_DISABLE_LENGTH_VERIFICATION);
m_hasAutenticated = false;
}
@@ -222,15 +225,20 @@ namespace Duplicati.Library.Backend
if (systemIO.FileExists(targetFilePath))
systemIO.FileDelete(targetFilePath);
+ var sourceFileInfo = new FileInfo(sourceFilePath);
+ var sourceFileLength = sourceFileInfo.Exists ? (long?)sourceFileInfo.Length : null;
+
systemIO.FileMove(sourceFilePath, targetFilePath);
+ if (m_verifyDestinationLength)
+ VerifyMatchingSize(targetFilePath, null, sourceFileLength);
}
else
{
- systemIO.FileCopy(sourceFilePath, targetFilePath, true);
+ systemIO.FileCopy(sourceFilePath, targetFilePath, true);
+ if (m_verifyDestinationLength)
+ VerifyMatchingSize(targetFilePath, sourceFilePath);
}
- VerifyMatchingSize(targetFilePath, sourceFilePath);
-
return Task.FromResult(true);
}
@@ -255,6 +263,8 @@ namespace Duplicati.Library.Backend
new CommandLineArgument(OPTION_ALTERNATE_PATHS, CommandLineArgument.ArgumentType.Path, Strings.FileBackend.AlternateTargetPathsShort, Strings.FileBackend.AlternateTargetPathsLong(OPTION_DESTINATION_MARKER, System.IO.Path.PathSeparator)),
new CommandLineArgument(OPTION_MOVE_FILE, CommandLineArgument.ArgumentType.Boolean, Strings.FileBackend.UseMoveForPutShort, Strings.FileBackend.UseMoveForPutLong),
new CommandLineArgument(OPTION_FORCE_REAUTH, CommandLineArgument.ArgumentType.Boolean, Strings.FileBackend.ForceReauthShort, Strings.FileBackend.ForceReauthLong),
+ new CommandLineArgument(OPTION_DISABLE_LENGTH_VERIFICATION, CommandLineArgument.ArgumentType.Boolean, Strings.FileBackend.DisableLengthVerificationShort, Strings.FileBackend.DisableLengthVerificationShort),
+
});
}
@@ -426,7 +436,8 @@ namespace Duplicati.Library.Backend
if (!targetFileInfo.Exists)
throw new FileMissingException($"Target file does not exist. Target: {targetFilePath}");
- long? sourceStreamLength = Utility.Utility.GetStreamLength(sourceStream, out bool isStreamPostion);
+ bool isStreamPostion = false;
+ long? sourceStreamLength = sourceStream == null ? null : Utility.Utility.GetStreamLength(sourceStream, out isStreamPostion);
if (sourceStreamLength.HasValue && targetFileInfo.Length != sourceStreamLength.Value)
throw new FileMissingException($"Target file size ({targetFileInfo.Length:n0}) is different from the source length ({sourceStreamLength.Value:n0}){(isStreamPostion ? " - ending stream position)" : "")}. Target: {targetFilePath}");
diff --git a/Duplicati/Library/Backend/File/Strings.cs b/Duplicati/Library/Backend/File/Strings.cs
index 3bb2659b6..f5bb19aa7 100644
--- a/Duplicati/Library/Backend/File/Strings.cs
+++ b/Duplicati/Library/Backend/File/Strings.cs
@@ -17,5 +17,7 @@ namespace Duplicati.Library.Backend.Strings {
public static string UseMoveForPutShort { get { return LC.L(@"Move the file instead of copying it"); } }
public static string ForceReauthShort { get { return LC.L(@"Force authentication against remote share"); } }
public static string ForceReauthLong { get { return LC.L(@"If this option is set, any existing authentication against the remote share is dropped before attempting to authenticate"); } }
+ public static string DisableLengthVerificationShort { get { return LC.L(@"Disable length verification"); } }
+ public static string DisableLengthVerificationLong { get { return LC.L(@"As an extra precaution the uploaded file length will be checked against the local source length."); } }
}
}