Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8658:d326adcfd518 HEAD
dict quota: When updating quota don't look up the current byte/msg limit if there's no limit for it.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 19 Jan 2009 15:30:58 -0500 |
parents | e579406fdab6 |
children | c349c4a106af |
files | src/plugins/quota/quota.c |
diffstat | 1 files changed, 31 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota.c Mon Jan 19 12:08:51 2009 -0500 +++ b/src/plugins/quota/quota.c Mon Jan 19 15:30:58 2009 -0500 @@ -741,7 +741,7 @@ struct quota_root *const *roots; const char *mailbox_name; unsigned int i, count; - uint64_t current, limit, left; + uint64_t bytes_limit, count_limit, current, limit, left; int ret; ctx->limits_set = TRUE; @@ -753,29 +753,37 @@ if (!quota_root_is_visible(roots[i], ctx->box, TRUE)) continue; - ret = quota_get_resource(roots[i], mailbox_name, - QUOTA_NAME_STORAGE_BYTES, - ¤t, &limit); - if (ret > 0) { - current += ctx->bytes_used; - left = limit < current ? 0 : limit - current; - if (ctx->bytes_left > left) - ctx->bytes_left = left; - } else if (ret < 0) { - ctx->failed = TRUE; - return -1; + (void)quota_root_get_rule_limits(roots[i], mailbox_name, + &bytes_limit, &count_limit); + + if (bytes_limit > 0) { + ret = quota_get_resource(roots[i], mailbox_name, + QUOTA_NAME_STORAGE_BYTES, + ¤t, &limit); + if (ret > 0) { + current += ctx->bytes_used; + left = limit < current ? 0 : limit - current; + if (ctx->bytes_left > left) + ctx->bytes_left = left; + } else if (ret < 0) { + ctx->failed = TRUE; + return -1; + } } - - ret = quota_get_resource(roots[i], mailbox_name, - QUOTA_NAME_MESSAGES, ¤t, &limit); - if (ret > 0) { - current += ctx->count_used; - left = limit < current ? 0 : limit - current; - if (ctx->count_left > left) - ctx->count_left = left; - } else if (ret < 0) { - ctx->failed = TRUE; - return -1; + + if (count_limit > 0) { + ret = quota_get_resource(roots[i], mailbox_name, + QUOTA_NAME_MESSAGES, + ¤t, &limit); + if (ret > 0) { + current += ctx->count_used; + left = limit < current ? 0 : limit - current; + if (ctx->count_left > left) + ctx->count_left = left; + } else if (ret < 0) { + ctx->failed = TRUE; + return -1; + } } } return 0;