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.
This commit is contained in:
Nick Craig-Wood 2024-11-08 14:01:51 +00:00
parent f307d929a8
commit 740f6b318c

View File

@ -572,6 +572,17 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (o fs.Objec
if err != nil { if err != nil {
return nil, err 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) { err = f.pacer.Call(func() (bool, error) {
params := url.Values{} params := url.Values{}
params.Set("file_id", strconv.FormatInt(resp.File.ID, 10)) params.Set("file_id", strconv.FormatInt(resp.File.ID, 10))