From 740f6b318c430147cc1d561049b7b70884cdef5c Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 8 Nov 2024 14:01:51 +0000 Subject: [PATCH] putio: fix server side copying over existing object This was causing a conflict error. This was fixed by checking for the existing object and deleting it after the file was server side copied. --- backend/putio/fs.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/putio/fs.go b/backend/putio/fs.go index cc21cac00..cdd89ceba 100644 --- a/backend/putio/fs.go +++ b/backend/putio/fs.go @@ -572,6 +572,17 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (o fs.Objec if err != nil { return nil, err } + + // We have successfully copied the file to random name + // Check to see if file already exists first and delete it if so + existingObj, err := f.NewObject(ctx, remote) + if err == nil { + err = existingObj.Remove(ctx) + if err != nil { + return nil, fmt.Errorf("server side copy: failed to remove existing file: %w", err) + } + } + err = f.pacer.Call(func() (bool, error) { params := url.Values{} params.Set("file_id", strconv.FormatInt(resp.File.ID, 10))