"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
compress: fix error handling to not use or return nil objects #6434
Nick Craig-Wood07efdb55fa02
diff --git a/backend/compress/compress.go b/backend/compress/compress.goindex b0ada83c6..6429e5a7e 100644--- a/backend/compress/compress.go+++ b/backend/compress/compress.go@@ -373,7 +373,10 @@ func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error) {}// Create our Objecto, err := f.Fs.NewObject(ctx, makeDataName(remote, meta.CompressionMetadata.Size, meta.Mode))- return f.newObject(o, mo, meta), err+ if err != nil {+ return nil, err+ }+ return f.newObject(o, mo, meta), nil}// checkCompressAndType checks if an object is compressible and determines it's mime type@@ -677,7 +680,7 @@ func (f *Fs) putWithCustomFunctions(ctx context.Context, in io.Reader, src fs.Ob}return nil, err}- return f.newObject(dataObject, mo, meta), err+ return f.newObject(dataObject, mo, meta), nil}// Put in to the remote path with the modTime given of the given size@@ -1097,6 +1100,9 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, oporigName := o.Remote()if o.meta.Mode != Uncompressed || compressible {newObject, err = o.f.putWithCustomFunctions(ctx, in, o.f.wrapInfo(src, origName, src.Size()), options, o.f.Fs.Put, updateMeta, compressible, mimeType)+ if err != nil {+ return err+ }if newObject.Object.Remote() != o.Object.Remote() {if removeErr := o.Object.Remove(ctx); removeErr != nil {return removeErr@@ -1110,9 +1116,9 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op}// If we are, just update the object and metadatanewObject, err = o.f.putWithCustomFunctions(ctx, in, src, options, update, updateMeta, compressible, mimeType)- }- if err != nil {- return err+ if err != nil {+ return err+ }}// Update object metadata and returno.Object = newObject.Object