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

hash: allow runtime configuration of supported hashes for testing

Nick Craig-Wood251a8e3c394f
diff --git a/fs/hash/hash.go b/fs/hash/hash.go
index 4540b40cf..23956cee6 100644
--- a/fs/hash/hash.go
+++ b/fs/hash/hash.go
@@ -55,6 +55,16 @@ func RegisterHash(name, alias string, width int, newFunc func() hash.Hash) Type
return hashType
}
+// SupportOnly makes the hash package only support the types passed
+// in. Used for testing.
+//
+// It returns the previously supported types.
+func SupportOnly(new []Type) (old []Type) {
+ old = supported
+ supported = new
+ return old
+}
+
// ErrUnsupported should be returned by filesystem,
// if it is requested to deliver an unsupported hash type.
var ErrUnsupported = errors.New("hash type not supported")