From 203f115661608b06d6e972443405a3efb51614c6 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:05:20 +0100 Subject: [PATCH] local: configurable supported hashes --- backend/local/local.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backend/local/local.go b/backend/local/local.go index 1a96d8036..f2c71d9d4 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -308,6 +308,12 @@ only useful for reading. Help: "The last status change time.", }}, }, + { + Name: "hashes", + Help: `Comma separated list of supported checksum types.`, + Default: fs.CommaSepList{}, + Advanced: true, + }, { Name: config.ConfigEncoding, Help: config.ConfigEncodingHelp, @@ -334,6 +340,7 @@ type Options struct { NoSparse bool `config:"no_sparse"` NoSetModTime bool `config:"no_set_modtime"` TimeType timeType `config:"time_type"` + Hashes fs.CommaSepList `config:"hashes"` Enc encoder.MultiEncoder `config:"encoding"` NoClone bool `config:"no_clone"` } @@ -1019,6 +1026,19 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string // Hashes returns the supported hash sets. func (f *Fs) Hashes() hash.Set { + if len(f.opt.Hashes) > 0 { + // Return only configured hashes. + // Note: Could have used hash.SupportOnly to limit supported hashes for all hash related features. + var supported hash.Set + for _, hashName := range f.opt.Hashes { + var ht hash.Type + if err := ht.Set(hashName); err != nil { + fs.Infof(nil, "Invalid token %q in hash string %q", hashName, f.opt.Hashes.String()) + } + supported.Add(ht) + } + return supported + } return hash.Supported() }