forked from TrueCloudLab/rclone
box: cancel in progress multipart uploads and copies on rclone exit #4300
This commit is contained in:
parent
47b17dc1bb
commit
a41a294e1d
1 changed files with 7 additions and 8 deletions
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/rclone/rclone/backend/box/api"
|
"github.com/rclone/rclone/backend/box/api"
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fs/accounting"
|
"github.com/rclone/rclone/fs/accounting"
|
||||||
|
"github.com/rclone/rclone/lib/atexit"
|
||||||
"github.com/rclone/rclone/lib/rest"
|
"github.com/rclone/rclone/lib/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -182,15 +183,13 @@ func (o *Object) uploadMultipart(ctx context.Context, in io.Reader, leaf, direct
|
||||||
fs.Debugf(o, "Multipart upload session started for %d parts of size %v", session.TotalParts, fs.SizeSuffix(chunkSize))
|
fs.Debugf(o, "Multipart upload session started for %d parts of size %v", session.TotalParts, fs.SizeSuffix(chunkSize))
|
||||||
|
|
||||||
// Cancel the session if something went wrong
|
// Cancel the session if something went wrong
|
||||||
defer func() {
|
defer atexit.OnError(&err, func() {
|
||||||
if err != nil {
|
fs.Debugf(o, "Cancelling multipart upload: %v", err)
|
||||||
fs.Debugf(o, "Cancelling multipart upload: %v", err)
|
cancelErr := o.abortUpload(ctx, session.ID)
|
||||||
cancelErr := o.abortUpload(ctx, session.ID)
|
if cancelErr != nil {
|
||||||
if cancelErr != nil {
|
fs.Logf(o, "Failed to cancel multipart upload: %v", cancelErr)
|
||||||
fs.Logf(o, "Failed to cancel multipart upload: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
|
|
||||||
// unwrap the accounting from the input, we use wrap to put it
|
// unwrap the accounting from the input, we use wrap to put it
|
||||||
// back on after the buffering
|
// back on after the buffering
|
||||||
|
|
Loading…
Reference in a new issue