diff --git a/cmd/admin-bucket-handlers.go b/cmd/admin-bucket-handlers.go index 4ea93878f..6a46a634c 100644 --- a/cmd/admin-bucket-handlers.go +++ b/cmd/admin-bucket-handlers.go @@ -82,10 +82,21 @@ func (a adminAPIHandlers) PutBucketQuotaConfigHandler(w http.ResponseWriter, r * return } - updatedAt, err := globalBucketMetadataSys.Update(ctx, bucket, bucketQuotaConfigFile, data) - if err != nil { - writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) - return + var updatedAt time.Time + // Remove the bucket quota configuration when the quota type is not set(from: mc quota clear alias/bucket). + if quotaConfig.Size == 0 && quotaConfig.Quota == 0 { + updatedAt, err = globalBucketMetadataSys.Delete(ctx, bucket, bucketQuotaConfigFile) + if err != nil { + writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) + return + } + data = nil + } else { + updatedAt, err = globalBucketMetadataSys.Update(ctx, bucket, bucketQuotaConfigFile, data) + if err != nil { + writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) + return + } } bucketMeta := madmin.SRBucketMeta{ @@ -94,9 +105,6 @@ func (a adminAPIHandlers) PutBucketQuotaConfigHandler(w http.ResponseWriter, r * Quota: data, UpdatedAt: updatedAt, } - if quotaConfig.Size == 0 && quotaConfig.Quota == 0 { - bucketMeta.Quota = nil - } // Call site replication hook. replLogIf(ctx, globalSiteReplicationSys.BucketMetaHook(ctx, bucketMeta))