cleanUpBucket removes all pending multipart uploads for a given bucket over the age of maxAge
(ctx context.Context, bucket string, maxAge time.Duration, uploads []*objectstorage.MultipartUpload)
| 654 | |
| 655 | // cleanUpBucket removes all pending multipart uploads for a given bucket over the age of maxAge |
| 656 | func (f *Fs) cleanUpBucket(ctx context.Context, bucket string, maxAge time.Duration, |
| 657 | uploads []*objectstorage.MultipartUpload) (err error) { |
| 658 | fs.Infof(f, "cleaning bucket %q of pending multipart uploads older than %v", bucket, maxAge) |
| 659 | for _, upload := range uploads { |
| 660 | if upload.TimeCreated != nil && upload.Object != nil && upload.UploadId != nil { |
| 661 | age := time.Since(upload.TimeCreated.Time) |
| 662 | what := fmt.Sprintf("pending multipart upload for bucket %q key %q dated %v (%v ago)", bucket, *upload.Object, |
| 663 | upload.TimeCreated, age) |
| 664 | if age > maxAge { |
| 665 | fs.Infof(f, "removing %s", what) |
| 666 | if operations.SkipDestructive(ctx, what, "remove pending upload") { |
| 667 | continue |
| 668 | } |
| 669 | _ = f.abortMultiPartUpload(ctx, upload.Bucket, upload.Object, upload.UploadId) |
| 670 | } |
| 671 | } else { |
| 672 | fs.Infof(f, "MultipartUpload doesn't have sufficient details to abort.") |
| 673 | } |
| 674 | } |
| 675 | return err |
| 676 | } |
| 677 | |
| 678 | // CleanUp removes all pending multipart uploads |
| 679 | func (f *Fs) cleanUp(ctx context.Context, maxAge time.Duration) (err error) { |
no test coverage detected