This commit is contained in:
dorman 2026-02-13 04:26:16 +08:00 committed by GitHub
commit 4edceaee93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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))