From ae6becec117ad2b8eb101e7eaee1a2a798d58d0b Mon Sep 17 00:00:00 2001 From: dormanze <553555147@qq.com> Date: Thu, 7 Aug 2025 15:00:06 +0800 Subject: [PATCH 1/2] fix clear bucket quota failed --- cmd/admin-bucket-handlers.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cmd/admin-bucket-handlers.go b/cmd/admin-bucket-handlers.go index 4ea93878f..ed70caf6e 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. + 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)) From c98f8695f5ecfd36e26b0c2483be4fb2e7e20dca Mon Sep 17 00:00:00 2001 From: dormanze <553555147@qq.com> Date: Thu, 7 Aug 2025 15:16:02 +0800 Subject: [PATCH 2/2] Update admin-bucket-handlers.go --- cmd/admin-bucket-handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/admin-bucket-handlers.go b/cmd/admin-bucket-handlers.go index ed70caf6e..6a46a634c 100644 --- a/cmd/admin-bucket-handlers.go +++ b/cmd/admin-bucket-handlers.go @@ -83,7 +83,7 @@ func (a adminAPIHandlers) PutBucketQuotaConfigHandler(w http.ResponseWriter, r * } var updatedAt time.Time - // Remove the bucket quota configuration when the quota type is not set. + // 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 {