# HG changeset patch # User Timo Sirainen # Date 1499904936 -10800 # Node ID 985aa5b0546b1fc6072d8e571d9c77ced78607ce # Parent 6af385105911126a3c3be9f60df04a8e948afc3a quota: Fix negative storage-based quota_warnings to work with count backend Finishes f9362223346d10a5866b376ed227b77b26ea4292, which fixed it for "messages" but not for "storage". diff -r 6af385105911 -r 985aa5b0546b src/plugins/quota/quota-private.h --- a/src/plugins/quota/quota-private.h Thu Jul 13 02:56:33 2017 +0300 +++ b/src/plugins/quota/quota-private.h Thu Jul 13 03:15:36 2017 +0300 @@ -102,6 +102,8 @@ /* 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 -r 6af385105911 -r 985aa5b0546b src/plugins/quota/quota-util.c --- a/src/plugins/quota/quota-util.c Thu Jul 13 02:56:33 2017 +0300 +++ b/src/plugins/quota/quota-util.c Thu Jul 13 03:15:36 2017 +0300 @@ -336,6 +336,8 @@ 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 -r 6af385105911 -r 985aa5b0546b src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Thu Jul 13 02:56:33 2017 +0300 +++ b/src/plugins/quota/quota.c Thu Jul 13 03:15:36 2017 +0300 @@ -858,7 +858,13 @@ 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; }