From: Timo Sirainen Date: Thu, 13 Jul 2017 00:15:36 +0000 (+0300) Subject: quota: Fix negative storage-based quota_warnings to work with count backend X-Git-Tag: 2.2.32.rc1~98 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2f1aba45f672ced4438813deb2a96cff259f2b7;p=thirdparty%2Fdovecot%2Fcore.git quota: Fix negative storage-based quota_warnings to work with count backend Finishes f9362223346d10a5866b376ed227b77b26ea4292, which fixed it for "messages" but not for "storage". --- diff --git a/src/plugins/quota/quota-private.h b/src/plugins/quota/quota-private.h index 069d32b086..21f5622884 100644 --- a/src/plugins/quota/quota-private.h +++ b/src/plugins/quota/quota-private.h @@ -102,6 +102,8 @@ struct quota_root_settings { /* Limits in default_rule override backend's quota limits */ unsigned int force_default_rule:1; + /* TRUE if any of the warning_rules have reverse==TRUE */ + unsigned int have_reverse_warnings:1; }; struct quota_root { diff --git a/src/plugins/quota/quota-util.c b/src/plugins/quota/quota-util.c index 3d783154bc..2758684b17 100644 --- a/src/plugins/quota/quota-util.c +++ b/src/plugins/quota/quota-util.c @@ -336,6 +336,8 @@ int quota_root_add_warning_rule(struct quota_root_settings *root_set, warning->command = p_strdup(root_set->set->pool, p+1); warning->rule = rule; warning->reverse = reverse; + if (reverse) + root_set->have_reverse_warnings = TRUE; quota_root_recalculate_relative_rules(root_set, root_set->default_rule.bytes_limit, diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index e006e77c31..b2e1c51a7e 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -858,7 +858,13 @@ struct quota_transaction_context *quota_transaction_begin(struct mailbox *box) continue; } - if (!(*rootp)->auto_updating) + /* If there are reverse quota_warnings, we'll need to track + how many bytes were expunged even with auto_updating roots. + (An alternative could be to get the current quota usage + before and after the expunges, but that's more complicated + and probably isn't any better.) */ + if (!(*rootp)->auto_updating || + (*rootp)->set->have_reverse_warnings) ctx->auto_updating = FALSE; }