Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

crypt: fix accounting when checking hashes on upload

Nick Craig-Wood455219f50110
diff --git a/backend/crypt/crypt.go b/backend/crypt/crypt.go
index c55acde52..a5c6cccd5 100644
--- a/backend/crypt/crypt.go
+++ b/backend/crypt/crypt.go
@@ -9,6 +9,7 @@ import (
"time"
"github.com/ncw/rclone/fs"
+ "github.com/ncw/rclone/fs/accounting"
"github.com/ncw/rclone/fs/config/configmap"
"github.com/ncw/rclone/fs/config/configstruct"
"github.com/ncw/rclone/fs/config/obscure"
@@ -331,7 +332,13 @@ func (f *Fs) put(in io.Reader, src fs.ObjectInfo, options []fs.OpenOption, put p
if err != nil {
return nil, err
}
+ // unwrap the accounting
+ var wrap accounting.WrapFn
+ wrappedIn, wrap = accounting.UnWrap(wrappedIn)
+ // add the hasher
wrappedIn = io.TeeReader(wrappedIn, hasher)
+ // wrap the accounting back on
+ wrappedIn = wrap(wrappedIn)
}
// Transfer the data