forked from TrueCloudLab/rclone
qingstor: cancel in progress multipart uploads on rclone exit #4300
This commit is contained in:
parent
2c10ce64aa
commit
49a7d08a40
1 changed files with 9 additions and 5 deletions
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
|
"github.com/rclone/rclone/lib/atexit"
|
||||||
qs "github.com/yunify/qingstor-sdk-go/v3/service"
|
qs "github.com/yunify/qingstor-sdk-go/v3/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -346,12 +347,15 @@ func (mu *multiUploader) multiPartUpload(firstBuf io.ReadSeeker) (err error) {
|
||||||
if err = mu.initiate(); err != nil {
|
if err = mu.initiate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
|
||||||
// Abort the transfer if returning an error
|
// Cancel the session if something went wrong
|
||||||
if err != nil {
|
defer atexit.OnError(&err, func() {
|
||||||
_ = mu.abort()
|
fs.Debugf(mu, "Cancelling multipart upload: %v", err)
|
||||||
|
cancelErr := mu.abort()
|
||||||
|
if cancelErr != nil {
|
||||||
|
fs.Logf(mu, "Failed to cancel multipart upload: %v", cancelErr)
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
|
|
||||||
ch := make(chan chunk, mu.cfg.concurrency)
|
ch := make(chan chunk, mu.cfg.concurrency)
|
||||||
for i := 0; i < mu.cfg.concurrency; i++ {
|
for i := 0; i < mu.cfg.concurrency; i++ {
|
||||||
|
|
Loading…
Add table
Reference in a new issue