"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
crypt: Implement Optional methods SetTier, GetTier - fixes #2895
Nick Craig-Woodeeab7a0a4342
diff --git a/backend/crypt/crypt.go b/backend/crypt/crypt.goindex 6e76cde9f..234b1b1cf 100644--- a/backend/crypt/crypt.go+++ b/backend/crypt/crypt.go@@ -169,6 +169,8 @@ func NewFs(name, rpath string, m configmap.Mapper) (fs.Fs, error) {WriteMimeType: false,BucketBased: true,CanHaveEmptyDirectories: true,+ SetTier: true,+ GetTier: true,}).Fill(f).Mask(wrappedFs).WrapsFs(f, wrappedFs)return f, err@@ -839,6 +841,34 @@ func (o *ObjectInfo) Hash(hash hash.Type) (string, error) {return "", nil}+// ID returns the ID of the Object if known, or "" if not+func (o *Object) ID() string {+ do, ok := o.Object.(fs.IDer)+ if !ok {+ return ""+ }+ return do.ID()+}++// SetTier performs changing storage tier of the Object if+// multiple storage classes supported+func (o *Object) SetTier(tier string) error {+ do, ok := o.Object.(fs.SetTierer)+ if !ok {+ return errors.New("crypt: underlying remote does not support SetTier")+ }+ return do.SetTier(tier)+}++// GetTier returns storage tier or class of the Object+func (o *Object) GetTier() string {+ do, ok := o.Object.(fs.GetTierer)+ if !ok {+ return ""+ }+ return do.GetTier()+}+// Check the interfaces are satisfiedvar (_ fs.Fs = (*Fs)(nil)@@ -860,4 +890,7 @@ var (_ fs.ObjectInfo = (*ObjectInfo)(nil)_ fs.Object = (*Object)(nil)_ fs.ObjectUnWrapper = (*Object)(nil)+ _ fs.IDer = (*Object)(nil)+ _ fs.SetTierer = (*Object)(nil)+ _ fs.GetTierer = (*Object)(nil))diff --git a/backend/crypt/crypt_test.go b/backend/crypt/crypt_test.goindex 4acf61a46..1558915c4 100644--- a/backend/crypt/crypt_test.go+++ b/backend/crypt/crypt_test.go@@ -21,8 +21,9 @@ func TestIntegration(t *testing.T) {t.Skip("Skipping as -remote not set")}fstests.Run(t, &fstests.Opt{- RemoteName: *fstest.RemoteName,- NilObject: (*crypt.Object)(nil),+ RemoteName: *fstest.RemoteName,+ NilObject: (*crypt.Object)(nil),+ UnimplementableObjectMethods: []string{"MimeType"},})}@@ -42,6 +43,7 @@ func TestStandard(t *testing.T) {{Name: name, Key: "password", Value: obscure.MustObscure("potato")},{Name: name, Key: "filename_encryption", Value: "standard"},},+ UnimplementableObjectMethods: []string{"MimeType"},})}@@ -61,6 +63,7 @@ func TestOff(t *testing.T) {{Name: name, Key: "password", Value: obscure.MustObscure("potato2")},{Name: name, Key: "filename_encryption", Value: "off"},},+ UnimplementableObjectMethods: []string{"MimeType"},})}@@ -80,6 +83,7 @@ func TestObfuscate(t *testing.T) {{Name: name, Key: "password", Value: obscure.MustObscure("potato2")},{Name: name, Key: "filename_encryption", Value: "obfuscate"},},- SkipBadWindowsCharacters: true,+ SkipBadWindowsCharacters: true,+ UnimplementableObjectMethods: []string{"MimeType"},})}