forked from TrueCloudLab/rclone
pcloud: delete half uploaded files on upload error
Sometimes pcloud will leave a half uploaded file when the transfer actually failed. This patch deletes the file if it exists. This problem was spotted by the integration tests.
This commit is contained in:
parent
b4d86d5450
commit
32ab4e9ac6
2 changed files with 8 additions and 0 deletions
|
@ -1107,6 +1107,12 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio
|
||||||
return shouldRetry(resp, err)
|
return shouldRetry(resp, err)
|
||||||
})
|
})
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
if len(result.Items) != 1 {
|
if len(result.Items) != 1 {
|
||||||
|
|
|
@ -379,6 +379,8 @@ func Run(t *testing.T, opt *Opt) {
|
||||||
//
|
//
|
||||||
// It makes sure that aborting a file half way through does not create
|
// It makes sure that aborting a file half way through does not create
|
||||||
// a file on the remote.
|
// a file on the remote.
|
||||||
|
//
|
||||||
|
// go test -v -run 'TestIntegration/Test(Setup|Init|FsMkdir|FsPutError)$'
|
||||||
t.Run("TestFsPutError", func(t *testing.T) {
|
t.Run("TestFsPutError", func(t *testing.T) {
|
||||||
skipIfNotOk(t)
|
skipIfNotOk(t)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue