"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
fstest: add ability for mock objects and filesystems to have hashes
Nick Craig-Wood25662b9e051f
diff --git a/fstest/mockfs/mockfs.go b/fstest/mockfs/mockfs.goindex ed2d1b5e6..b036c57ce 100644--- a/fstest/mockfs/mockfs.go+++ b/fstest/mockfs/mockfs.go@@ -18,6 +18,7 @@ type Fs struct {root string // The root directory (OS path)features *fs.Features // optional featuresrootDir fs.DirEntries // directory listing of root+ hashes hash.Set // which hashes we support}// ErrNotImplemented is returned by unimplemented methods@@ -66,7 +67,12 @@ func (f *Fs) Precision() time.Duration {// Hashes returns the supported hash types of the filesystemfunc (f *Fs) Hashes() hash.Set {- return hash.NewHashSet()+ return f.hashes+}++// SetHashes sets the hashes that this supports+func (f *Fs) SetHashes(hashes hash.Set) {+ f.hashes = hashes}// Features returns the optional features of this Fsdiff --git a/fstest/mockobject/mockobject.go b/fstest/mockobject/mockobject.goindex dcf04792d..0d0c4516c 100644--- a/fstest/mockobject/mockobject.go+++ b/fstest/mockobject/mockobject.go@@ -178,6 +178,20 @@ func (o *ContentMockObject) Size() int64 {return int64(len(o.content))}+// Hash returns the selected checksum of the file+// If no checksum is available it returns ""+func (o *ContentMockObject) Hash(ctx context.Context, t hash.Type) (string, error) {+ hasher, err := hash.NewMultiHasherTypes(hash.NewHashSet(t))+ if err != nil {+ return "", err+ }+ _, err = hasher.Write(o.content)+ if err != nil {+ return "", err+ }+ return hasher.Sums()[t], nil+}+type readCloser struct{ io.Reader }func (r *readCloser) Close() error { return nil }