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

pcloud: delete half uploaded files on upload error

Nick Craig-Wood32ab4e9ac691
diff --git a/backend/pcloud/pcloud.go b/backend/pcloud/pcloud.go
index 8654e9ffa..ec390e513 100644
--- a/backend/pcloud/pcloud.go
+++ b/backend/pcloud/pcloud.go
@@ -1107,6 +1107,12 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio
return shouldRetry(resp, err)
})
if err != nil {
+ // sometimes pcloud leaves a half complete file on
+ // error, so delete it if it exists
+ delObj, delErr := o.fs.NewObject(o.remote)
+ if delErr == nil && delObj != nil {
+ _ = delObj.Remove()
+ }
return err
}
if len(result.Items) != 1 {
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index 4f2738860..5c4feb1f3 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -379,6 +379,8 @@ func Run(t *testing.T, opt *Opt) {
//
// It makes sure that aborting a file half way through does not create
// a file on the remote.
+ //
+ // go test -v -run 'TestIntegration/Test(Setup|Init|FsMkdir|FsPutError)$'
t.Run("TestFsPutError", func(t *testing.T) {
skipIfNotOk(t)