mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
check if container is empty before invoking DeleteContainer (#9733)
This commit is contained in:
parent
2bcb02f628
commit
d583f1ac0e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user