]> 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:06:23 +0000 (15:06 +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 25222c074709cca885cb6dda2270d45d63019cf2..b99764f8a49ed72c14f2307e638b9cabb3e5c052 100644 (file)
@@ -102,6 +102,8 @@ struct quota_root_settings {
 
        /* Limits in default_rule override backend's quota limits */
        bool force_default_rule:1;
+       /* TRUE if any of the warning_rules have reverse==TRUE */
+       bool 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 0a0de28402c82b38c883aacce3cc28ae6d097284..ced568ebcebcc6e335c6167b06de01eaa91d8ac0 100644 (file)
@@ -861,7 +861,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;
        }