From 086e8ecc50156d1017e5b807bdecc00b4fdc2a0e Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Fri, 18 Aug 2017 15:29:09 +0300 Subject: [PATCH] quota plugin: restructure quota_root_get_rule_limits() If the user has unlimited quota, we have no reason to find the real mailbox name. --- src/plugins/quota/quota.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index ced568ebce..4ef9765e68 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -483,7 +483,7 @@ static int quota_root_get_rule_limits(struct quota_root *root, { struct quota_rule *rule; int64_t bytes_limit, count_limit; - bool enabled; + int ret; *ignored_r = FALSE; @@ -499,11 +499,16 @@ static int quota_root_get_rule_limits(struct quota_root *root, /* if default rule limits are 0, user has unlimited quota. ignore any specific quota rules */ - enabled = bytes_limit != 0 || count_limit != 0; + if (bytes_limit != 0 || count_limit != 0) { + (void)mail_namespace_find_unalias(root->quota->user->namespaces, + &mailbox_name); + rule = quota_root_rule_find(root->set, mailbox_name); + ret = 1; + } else { + rule = NULL; + ret = 0; + } - (void)mail_namespace_find_unalias(root->quota->user->namespaces, - &mailbox_name); - rule = enabled ? quota_root_rule_find(root->set, mailbox_name) : NULL; if (rule != NULL) { if (!rule->ignore) { bytes_limit += rule->bytes_limit; @@ -517,7 +522,7 @@ static int quota_root_get_rule_limits(struct quota_root *root, *bytes_limit_r = bytes_limit <= 0 ? 0 : bytes_limit; *count_limit_r = count_limit <= 0 ? 0 : count_limit; - return enabled ? 1 : 0; + return ret; } static bool -- 2.47.3