MCPcopy
hub / github.com/minio/minio-go / cleanupBucket

Function cleanupBucket

functional_tests.go:210–240  ·  view source on GitHub ↗

Delete objects in given bucket, recursively

(bucketName string, c *minio.Client)

Source from the content-addressed store, hash-verified

208
209// Delete objects in given bucket, recursively
210func cleanupBucket(bucketName string, c *minio.Client) error {
211 // Create a done channel to control 'ListObjectsV2' go routine.
212 doneCh := make(chan struct{})
213 // Exit cleanly upon return.
214 defer close(doneCh)
215 // Iterate over all objects in the bucket via listObjectsV2 and delete
216 for objCh := range c.ListObjects(context.Background(), bucketName, minio.ListObjectsOptions{Recursive: true}) {
217 if objCh.Err != nil {
218 return objCh.Err
219 }
220 if objCh.Key != "" {
221 err := c.RemoveObject(context.Background(), bucketName, objCh.Key, minio.RemoveObjectOptions{})
222 if err != nil {
223 return err
224 }
225 }
226 }
227 for objPartInfo := range c.ListIncompleteUploads(context.Background(), bucketName, "", true) {
228 if objPartInfo.Err != nil {
229 return objPartInfo.Err
230 }
231 if objPartInfo.Key != "" {
232 err := c.RemoveIncompleteUpload(context.Background(), bucketName, objPartInfo.Key)
233 if err != nil {
234 return err
235 }
236 }
237 }
238 // objects are already deleted, clear the buckets now
239 return c.RemoveBucket(context.Background(), bucketName)
240}
241
242func cleanupVersionedBucket(bucketName string, c *minio.Client) error {
243 doneCh := make(chan struct{})

Calls 5

RemoveObjectMethod · 0.80
ListIncompleteUploadsMethod · 0.80
RemoveBucketMethod · 0.80
ListObjectsMethod · 0.45

Tested by

no test coverage detected