From e559194fb2a7e92b88ccaf065a1b817fcfe49772 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 19 Jul 2014 12:38:58 +0100 Subject: [PATCH] fs: Verify sizes are the same after transfer in Copy() --- fs/operations.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/operations.go b/fs/operations.go index 0fd62d90e..6b56792e5 100644 --- a/fs/operations.go +++ b/fs/operations.go @@ -142,6 +142,15 @@ func Copy(f Fs, dst, src Object) { return } + // Verify sizes are the same after transfer + if src.Size() != dst.Size() { + Stats.Error() + err = fmt.Errorf("Corrupted on transfer: sizes differ %d vs %d", src.Size(), dst.Size()) + Log(dst, "%s", err) + removeFailedCopy(dst) + return + } + // Verify md5sums are the same after transfer - ignoring blank md5sums srcMd5sum, md5sumErr := src.Md5sum() if md5sumErr != nil {