From 455219f501105ba4daed0dd282819d39ed029a6a Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 20 Aug 2018 15:29:35 +0100 Subject: [PATCH] crypt: fix accounting when checking hashes on upload In e52ecba295333d7ca70307fd7f3779d5b17c29af we forgot to unwrap and re-wrap the accounting which mean the the accounting was no longer first in the chain of readers. This lead to accounting inaccuracies in remotes which wrap and unwrap the reader again. --- backend/crypt/crypt.go | 7 +++++++ 1 file changed, 7 insertions(+) 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