forked from TrueCloudLab/rclone
ftp: add a small pause after failed upload before deleting file #2517
This fixes the integration tests for `serve ftp` which uses the ftp backend tests.
This commit is contained in:
parent
ef3526b3b8
commit
c473c7cb53
1 changed files with 6 additions and 1 deletions
|
@ -704,6 +704,11 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio
|
||||||
path := path.Join(o.fs.root, o.remote)
|
path := path.Join(o.fs.root, o.remote)
|
||||||
// remove the file if upload failed
|
// remove the file if upload failed
|
||||||
remove := func() {
|
remove := func() {
|
||||||
|
// Give the FTP server a chance to get its internal state in order after the error.
|
||||||
|
// The error may have been local in which case we closed the connection. The server
|
||||||
|
// may still be dealing with it for a moment. A sleep isn't ideal but I haven't been
|
||||||
|
// able to think of a better method to find out if the server has finished - ncw
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
removeErr := o.Remove()
|
removeErr := o.Remove()
|
||||||
if removeErr != nil {
|
if removeErr != nil {
|
||||||
fs.Debugf(o, "Failed to remove: %v", removeErr)
|
fs.Debugf(o, "Failed to remove: %v", removeErr)
|
||||||
|
@ -717,7 +722,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio
|
||||||
}
|
}
|
||||||
err = c.Stor(path, in)
|
err = c.Stor(path, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = c.Quit()
|
_ = c.Quit() // toss this connection to avoid sync errors
|
||||||
remove()
|
remove()
|
||||||
return errors.Wrap(err, "update stor")
|
return errors.Wrap(err, "update stor")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue