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

drive: fix incorrect remote after Update on object

Nick Craig-Wood65b2e378e099
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index 625f4a303..b07602bb4 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -3884,7 +3884,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
if err != nil {
return err
}
- newO, err := o.fs.newObjectWithInfo(ctx, src.Remote(), info)
+ newO, err := o.fs.newObjectWithInfo(ctx, o.remote, info)
if err != nil {
return err
}
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index b3bbc5724..46a6ff4b5 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -1522,9 +1522,12 @@ func Run(t *testing.T, opt *Opt) {
file1.Size = int64(buf.Len())
obj := findObject(ctx, t, f, file1.Path)
- obji := object.NewStaticObjectInfo(file1.Path, file1.ModTime, int64(len(contents)), true, nil, obj.Fs())
+ remoteBefore := obj.Remote()
+ obji := object.NewStaticObjectInfo(file1.Path+"-should-be-ignored.bin", file1.ModTime, int64(len(contents)), true, nil, obj.Fs())
err := obj.Update(ctx, in, obji)
require.NoError(t, err)
+ remoteAfter := obj.Remote()
+ assert.Equal(t, remoteBefore, remoteAfter, "Remote should not change")
file1.Hashes = hash.Sums()
// check the object has been updated