|
|
|
@ -624,6 +624,17 @@ func (a *azureObjects) ListBuckets(ctx context.Context) (buckets []minio.BucketI |
|
|
|
|
|
|
|
|
|
// DeleteBucket - delete a container on azure, uses Azure equivalent `ContainerURL.Delete`.
|
|
|
|
|
func (a *azureObjects) DeleteBucket(ctx context.Context, bucket string, forceDelete bool) error { |
|
|
|
|
if !forceDelete { |
|
|
|
|
// Check if the container is empty before deleting it.
|
|
|
|
|
result, err := a.ListObjects(ctx, bucket, "", "", "", 1) |
|
|
|
|
if err != nil { |
|
|
|
|
return azureToObjectError(err, bucket) |
|
|
|
|
} |
|
|
|
|
if len(result.Objects) > 0 { |
|
|
|
|
return minio.BucketNotEmpty{Bucket: bucket} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
containerURL := a.client.NewContainerURL(bucket) |
|
|
|
|
_, err := containerURL.Delete(ctx, azblob.ContainerAccessConditions{}) |
|
|
|
|
return azureToObjectError(err, bucket) |
|
|
|
|