rcat: fix slowdown on systems with multiple hashes

Before this fix rclone calculated all the hashes on transfer.  This
was particularly slow for the local backend.

After the fix we just calculate one hash which is enough for data
integrity.
This commit is contained in:
Nick Craig-Wood 2019-08-07 16:40:26 +01:00
parent 62b769a0a7
commit c014b2e66b

View file

@ -1222,8 +1222,9 @@ func Rcat(ctx context.Context, fdst fs.Fs, dstFileName string, in io.ReadCloser,
}()
in = tr.Account(in).WithBuffer()
hashOption := &fs.HashesOption{Hashes: fdst.Hashes()}
hash, err := hash.NewMultiHasherTypes(fdst.Hashes())
hashes := hash.NewHashSet(fdst.Hashes().GetOne()) // just pick one hash
hashOption := &fs.HashesOption{Hashes: hashes}
hash, err := hash.NewMultiHasherTypes(hashes)
if err != nil {
return nil, err
}