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

qingstor: cancel in progress multipart uploads on rclone exit #4300

Nick Craig-Wood49a7d08a4097
diff --git a/backend/qingstor/upload.go b/backend/qingstor/upload.go
index fb9202106..642a47c84 100644
--- a/backend/qingstor/upload.go
+++ b/backend/qingstor/upload.go
@@ -15,6 +15,7 @@ import (
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
+ "github.com/rclone/rclone/lib/atexit"
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 {
return err
}
- defer func() {
- // Abort the transfer if returning an error
- if err != nil {
- _ = mu.abort()
+
+ // Cancel the session if something went wrong
+ defer atexit.OnError(&err, func() {
+ 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)
for i := 0; i < mu.cfg.concurrency; i++ {