From 687cbf3ded9bf9ca111dfe4c17978c2cba33c6d3 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 11 May 2019 22:27:24 +0100 Subject: [PATCH] operations: if --ignore-checksum is in effect, don't calculate checksum Before this change we calculated the checksum which is potentially time consuming and then ignored the result. After the change we don't calculate the checksum if we are about to ignore it. --- fs/operations/operations.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/operations/operations.go b/fs/operations/operations.go index a6d61de28..ab2d7fd49 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -356,9 +356,7 @@ func Copy(f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Objec } // Verify hashes are the same after transfer - ignoring blank hashes - // TODO(klauspost): This could be extended, so we always create a hash type matching - // the destination, and calculate it while sending. - if hashType != hash.None { + if !fs.Config.IgnoreChecksum && hashType != hash.None { var srcSum string srcSum, err = src.Hash(hashType) if err != nil { @@ -370,7 +368,7 @@ func Copy(f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Objec if err != nil { fs.CountError(err) fs.Errorf(dst, "Failed to read hash: %v", err) - } else if !fs.Config.IgnoreChecksum && !hash.Equals(srcSum, dstSum) { + } else if !hash.Equals(srcSum, dstSum) { err = errors.Errorf("corrupted on transfer: %v hash differ %q vs %q", hashType, srcSum, dstSum) fs.Errorf(dst, "%v", err) fs.CountError(err)