Mercurial > dovecot > core-2.2
changeset 22148:3272674e4e5d
quota: Fix negative quota_warnings with count backend
For example this never triggered:
quota_warning = -messages=100%% quota-warning %u -100
The change to quota_alloc() to update the count_used doesn't seem to
actually fix anything right now, but it makes the code more correct.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 09 Jun 2017 12:07:00 +0300 |
parents | edc9369f9d60 |
children | 562c621a9073 |
files | src/plugins/quota/quota-private.h src/plugins/quota/quota-storage.c src/plugins/quota/quota.c |
diffstat | 3 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-private.h Wed May 31 14:39:55 2017 +0300 +++ b/src/plugins/quota/quota-private.h Fri Jun 09 12:07:00 2017 +0300 @@ -135,7 +135,9 @@ /* don't enforce quota when saving */ unsigned int no_enforcing:1; /* quota is automatically updated. update() should be called but the - bytes/count won't be used. */ + bytes won't be changed. count is still changed, because it's cheap + to do and it's internally used to figure out whether there have + been some changes and that quota_warnings should be checked. */ unsigned int auto_updating:1; /* If user has unlimited quota, disable quota tracking */ unsigned int disable_unlimited_tracking:1;
--- a/src/plugins/quota/quota-storage.c Wed May 31 14:39:55 2017 +0300 +++ b/src/plugins/quota/quota-storage.c Fri Jun 09 12:07:00 2017 +0300 @@ -398,8 +398,13 @@ qbox->expunge_qt->sync_transaction = qbox->sync_transaction_expunge; } - if (qbox->expunge_qt->auto_updating) + if (qbox->expunge_qt->auto_updating) { + /* even though backend doesn't care about size/count changes, + make sure count_used changes so quota_warnings are + executed */ + quota_free_bytes(qbox->expunge_qt, 0); return; + } /* we're in the middle of syncing the mailbox, so it's a bad idea to try and get the message sizes at this point. Rely on sizes that
--- a/src/plugins/quota/quota.c Wed May 31 14:39:55 2017 +0300 +++ b/src/plugins/quota/quota.c Fri Jun 09 12:07:00 2017 +0300 @@ -1331,10 +1331,10 @@ { uoff_t size; - if (ctx->auto_updating) - return; - if (mail_get_physical_size(mail, &size) == 0) - ctx->bytes_used += size; + if (!ctx->auto_updating) { + if (mail_get_physical_size(mail, &size) == 0) + ctx->bytes_used += size; + } ctx->bytes_ceil = ctx->bytes_ceil2; ctx->count_used++;