mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
drive: fix incorrect remote after Update on object
Before this change, when Object.Update was called in the drive backend, it overwrote the remote with that of the object info. This is incorrect - the remote doesn't change on Update and this patch fixes that and introduces a new test to make sure it is correct for all backends. This was noticed when doing Update of objects in a nested combine backend. See: https://forum.rclone.org/t/rclone-runtime-goroutine-stack-exceeds-1000000000-byte-limit/37912
This commit is contained in:
parent
dea6bdf3df
commit
65b2e378e0
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user