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: add MultiHasher.Sum() to retrieve a single specific hash

buengese28128161421f
diff --git a/fs/hash/hash.go b/fs/hash/hash.go
index 23b211fd3..8b49c2476 100644
--- a/fs/hash/hash.go
+++ b/fs/hash/hash.go
@@ -238,6 +238,15 @@ func (m *MultiHasher) Sums() map[Type]string {
return dst
}
+// Sum returns the specified hash from the multihasher
+func (m *MultiHasher) Sum(hashType Type) ([]byte, error) {
+ h, ok := m.h[hashType]
+ if !ok {
+ return nil, ErrUnsupported
+ }
+ return h.Sum(nil), nil
+}
+
// Size returns the number of bytes written
func (m *MultiHasher) Size() int64 {
return m.size