From d4cc3760e61e946a7bd13230ed6779eb805850f0 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 27 Jun 2023 12:46:55 +0100 Subject: [PATCH] putio: fix uploading to the wrong object on Update with overriden remote name In this commit we discovered a problem with objects being uploaded to the incorrect object name. It added an integration test for the problem. 65b2e378e0992d65 drive: fix incorrect remote after Update on object This test was tripped by the putio backend and this patch fixes the problem. --- backend/putio/fs.go | 5 ++++- backend/putio/object.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/putio/fs.go b/backend/putio/fs.go index cbcda547f..2a3286133 100644 --- a/backend/putio/fs.go +++ b/backend/putio/fs.go @@ -252,9 +252,12 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options . // This will create a duplicate if we upload a new file without // checking to see if there is one already - use Put() for that. func (f *Fs) PutUnchecked(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (o fs.Object, err error) { + return f.putUnchecked(ctx, in, src, src.Remote(), options...) +} + +func (f *Fs) putUnchecked(ctx context.Context, in io.Reader, src fs.ObjectInfo, remote string, options ...fs.OpenOption) (o fs.Object, err error) { // defer log.Trace(f, "src=%+v", src)("o=%+v, err=%v", &o, &err) size := src.Size() - remote := src.Remote() leaf, directoryID, err := f.dirCache.FindPath(ctx, remote, true) if err != nil { return nil, err diff --git a/backend/putio/object.go b/backend/putio/object.go index bd03982ca..86edb008f 100644 --- a/backend/putio/object.go +++ b/backend/putio/object.go @@ -275,7 +275,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op if err != nil { return err } - newObj, err := o.fs.PutUnchecked(ctx, in, src, options...) + newObj, err := o.fs.putUnchecked(ctx, in, src, o.remote, options...) if err != nil { return err }