"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
storj: fix uploading to the wrong object on Update with overriden remote name
Nick Craig-Wood389565f5e269
diff --git a/backend/storj/fs.go b/backend/storj/fs.goindex 6774cc949..7f7d4d4a6 100644--- a/backend/storj/fs.go+++ b/backend/storj/fs.go@@ -528,7 +528,11 @@ func (f *Fs) NewObject(ctx context.Context, relative string) (_ fs.Object, err e// May create the object even if it returns an error - if so will return the// object and the error, otherwise will return nil and the errorfunc (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (_ fs.Object, err error) {- fs.Debugf(f, "cp input ./%s # %+v %d", src.Remote(), options, src.Size())+ return f.put(ctx, in, src, src.Remote(), options...)+}++func (f *Fs) put(ctx context.Context, in io.Reader, src fs.ObjectInfo, remote string, options ...fs.OpenOption) (_ fs.Object, err error) {+ fs.Debugf(f, "cp input ./%s # %+v %d", remote, options, src.Size())// Reject options we don't support.for _, option := range options {@@ -539,7 +543,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .}}- bucketName, bucketPath := f.absolute(src.Remote())+ bucketName, bucketPath := f.absolute(remote)upload, err := f.project.UploadObject(ctx, bucketName, bucketPath, nil)if err != nil {@@ -549,7 +553,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .if err != nil {aerr := upload.Abort()if aerr != nil && !errors.Is(aerr, uplink.ErrUploadDone) {- fs.Errorf(f, "cp input ./%s %+v: %+v", src.Remote(), options, aerr)+ fs.Errorf(f, "cp input ./%s %+v: %+v", remote, options, aerr)}}}()@@ -574,7 +578,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .}err = fserrors.RetryError(err)- fs.Errorf(f, "cp input ./%s %+v: %+v\n", src.Remote(), options, err)+ fs.Errorf(f, "cp input ./%s %+v: %+v\n", remote, options, err)return nil, err}@@ -601,7 +605,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .return nil, err}- return newObjectFromUplink(f, src.Remote(), upload.Info()), nil+ return newObjectFromUplink(f, remote, upload.Info()), nil}// PutStream uploads to the remote path with the modTime given of indeterminatediff --git a/backend/storj/object.go b/backend/storj/object.goindex 9bb6e67cc..ea85026af 100644--- a/backend/storj/object.go+++ b/backend/storj/object.go@@ -176,9 +176,9 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (_ io.ReadC// But for unknown-sized objects (indicated by src.Size() == -1), Upload should either// return an error or update the object properly (rather than e.g. calling panic).func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error) {- fs.Debugf(o, "cp input ./%s %+v", src.Remote(), options)+ fs.Debugf(o, "cp input ./%s %+v", o.Remote(), options)- oNew, err := o.fs.Put(ctx, in, src, options...)+ oNew, err := o.fs.put(ctx, in, src, o.Remote(), options...)if err == nil {*o = *(oNew.(*Object))