]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Fix negative storage-based quota_warnings to work with count backend
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 13 Jul 2017 00:15:36 +0000 (03:15 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 13 Jul 2017 12:20:46 +0000 (15:20 +0300)
Finishes f9362223346d10a5866b376ed227b77b26ea4292, which fixed it for
"messages" but not for "storage".

src/plugins/quota/quota-private.h
src/plugins/quota/quota-util.c
src/plugins/quota/quota.c

index 069d32b0860a1f0c046489ddb5ae168a7f8965f6..21f56228840e2714154382a9f43b2ac1261cb9a4 100644 (file)
@@ -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 {
index 3d783154bccc6dd4ff729474a336b2cbe665d162..2758684b17084c7c2add268ace0090945820ad5a 100644 (file)
@@ -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,
index e006e77c31fb0a64e8b5871a264a6caf3da382fa..b2e1c51a7e550cc497343d47433c8f262b686b3f 100644 (file)
@@ -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;
        }