diff --git a/cmd/admin-bucket-handlers.go b/cmd/admin-bucket-handlers.go index bba399f12..21b39c58b 100644 --- a/cmd/admin-bucket-handlers.go +++ b/cmd/admin-bucket-handlers.go @@ -94,7 +94,7 @@ func (a adminAPIHandlers) PutBucketQuotaConfigHandler(w http.ResponseWriter, r * Quota: data, UpdatedAt: updatedAt, } - if quotaConfig.Quota == 0 { + if quotaConfig.Size == 0 || quotaConfig.Quota == 0 { bucketMeta.Quota = nil } diff --git a/cmd/bucket-quota.go b/cmd/bucket-quota.go index db2b968f2..1b440ae03 100644 --- a/cmd/bucket-quota.go +++ b/cmd/bucket-quota.go @@ -35,8 +35,8 @@ type BucketQuotaSys struct { // Get - Get quota configuration. func (sys *BucketQuotaSys) Get(ctx context.Context, bucketName string) (*madmin.BucketQuota, error) { - qCfg, _, err := globalBucketMetadataSys.GetQuotaConfig(ctx, bucketName) - return qCfg, err + cfg, _, err := globalBucketMetadataSys.GetQuotaConfig(ctx, bucketName) + return cfg, err } // NewBucketQuotaSys returns initialized BucketQuotaSys @@ -107,8 +107,16 @@ func (sys *BucketQuotaSys) enforceQuotaHard(ctx context.Context, bucket string, return err } - if q != nil && q.Type == madmin.HardQuota && q.Size > 0 { - if uint64(size) >= q.Size { // check if file size already exceeds the quota + var quotaSize uint64 + if q != nil && q.Type == madmin.HardQuota { + if q.Size > 0 { + quotaSize = q.Size + } else if q.Quota > 0 { + quotaSize = q.Quota + } + } + if quotaSize > 0 { + if uint64(size) >= quotaSize { // check if file size already exceeds the quota return BucketQuotaExceeded{Bucket: bucket} } @@ -117,7 +125,7 @@ func (sys *BucketQuotaSys) enforceQuotaHard(ctx context.Context, bucket string, return err } - if bui.Size > 0 && ((bui.Size + uint64(size)) >= q.Size) { + if bui.Size > 0 && ((bui.Size + uint64(size)) >= quotaSize) { return BucketQuotaExceeded{Bucket: bucket} } } diff --git a/go.mod b/go.mod index 1b8361c8f..b7aec18fa 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/minio/dperf v0.5.0 github.com/minio/highwayhash v1.0.2 github.com/minio/kes-go v0.2.0 - github.com/minio/madmin-go/v3 v3.0.17 + github.com/minio/madmin-go/v3 v3.0.18 github.com/minio/minio-go/v7 v7.0.63 github.com/minio/mux v1.9.0 github.com/minio/pkg/v2 v2.0.0 diff --git a/go.sum b/go.sum index 829e74cec..a255914e1 100644 --- a/go.sum +++ b/go.sum @@ -484,8 +484,8 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/kes-go v0.2.0 h1:HA33arq9s3MErbsj3PAXFVfFo4U4yw7lTKQ5kWFrpCA= github.com/minio/kes-go v0.2.0/go.mod h1:VorHLaIYis9/MxAHAtXN4d8PUMNKhIxTIlvFt0hBOEo= -github.com/minio/madmin-go/v3 v3.0.17 h1:fm3TIMK7hxCpgztO2GHN6Lxq66zYPWlmrS8M9YWvoSE= -github.com/minio/madmin-go/v3 v3.0.17/go.mod h1:B2EgtEGrfWx+AkXv+OAcS6IHwoIJcd1p75QfDPSPd6Q= +github.com/minio/madmin-go/v3 v3.0.18 h1:HuuuGf+uv6O3wlbx/VgIPjXGtVQXMrNk9qcrtE5VusU= +github.com/minio/madmin-go/v3 v3.0.18/go.mod h1:B2EgtEGrfWx+AkXv+OAcS6IHwoIJcd1p75QfDPSPd6Q= github.com/minio/mc v0.0.0-20230902212803-e2056fb05789 h1:vMQHDxJl5JHSXtNT8JmeLWHmQTd3r6X9gG+gquxqp7A= github.com/minio/mc v0.0.0-20230902212803-e2056fb05789/go.mod h1:M/RN4OtnloGZLgLd/HicgzoEQdYXYz0taYqZzoBqVrc= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=