forked from TrueCloudLab/rclone
qingstor: try harder to cancel failed multipart uploads
This commit is contained in:
parent
72eba4dbb6
commit
84caf1e158
1 changed files with 9 additions and 8 deletions
|
@ -341,12 +341,17 @@ func (mu *multiUploader) abort() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiPartUpload upload a multiple object into QingStor
|
// multiPartUpload upload a multiple object into QingStor
|
||||||
func (mu *multiUploader) multiPartUpload(firstBuf io.ReadSeeker) error {
|
func (mu *multiUploader) multiPartUpload(firstBuf io.ReadSeeker) (err error) {
|
||||||
var err error
|
// Initiate an multi-part upload
|
||||||
//Initiate an multi-part upload
|
|
||||||
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
|
||||||
|
if err != nil {
|
||||||
|
_ = mu.abort()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
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++ {
|
||||||
|
@ -400,9 +405,5 @@ func (mu *multiUploader) multiPartUpload(firstBuf io.ReadSeeker) error {
|
||||||
close(ch)
|
close(ch)
|
||||||
mu.wg.Wait()
|
mu.wg.Wait()
|
||||||
// Complete Multipart Upload
|
// Complete Multipart Upload
|
||||||
err = mu.complete()
|
return mu.complete()
|
||||||
if mu.getErr() != nil || err != nil {
|
|
||||||
_ = mu.abort()
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue