Delete objects in given bucket, recursively
(bucketName string, c *minio.Client)
| 208 | |
| 209 | // Delete objects in given bucket, recursively |
| 210 | func 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 | |
| 242 | func cleanupVersionedBucket(bucketName string, c *minio.Client) error { |
| 243 | doneCh := make(chan struct{}) |
no test coverage detected