lsjson: Add --hash-type parameter and use it in lsf to speed up hashing

Before this change if you specified --hash MD5 in rclone lsf it would
calculate all the hashes and just return the MD5 hash which was very
slow on the local backend.

Likewise specifying --hash on rclone lsjson was equally slow.

This change introduces the --hash-type flag (and corresponding
internal parameter) so that the hashes required can be selected in
lsjson.

This is used internally in lsf when the --hash parameter is selected
to speed up the hashing by only hashing with the one hash specified.

Fixes #4181
This commit is contained in:
Nick Craig-Wood
2020-04-29 16:09:45 +01:00
parent a3f0992a22
commit f37af9afec
3 changed files with 41 additions and 15 deletions
+1
View File
@@ -185,6 +185,7 @@ func Lsf(ctx context.Context, fsrc fs.Fs, out io.Writer) error {
case 'h':
list.AddHash(hashType)
opt.ShowHash = true
opt.HashTypes = []string{hashType.String()}
case 'i':
list.AddID()
case 'm':