From: Stephan Bosch Date: Fri, 16 Nov 2018 14:18:20 +0000 (+0100) Subject: trash: Perform check for achievement of quota usage reduction target in a separate... X-Git-Tag: 2.4.1~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b3398502e32f6dfef7aa297e083c4cba6a63cf2;p=thirdparty%2Fdovecot%2Fcore.git trash: Perform check for achievement of quota usage reduction target in a separate function --- diff --git a/src/plugins/trash/trash-plugin.c b/src/plugins/trash/trash-plugin.c index 40a3ece20a..fe05be564e 100644 --- a/src/plugins/trash/trash-plugin.c +++ b/src/plugins/trash/trash-plugin.c @@ -163,6 +163,14 @@ trash_clean_mailbox_get_next(struct trash_clean_mailbox *tcbox, return 1; } +static inline bool trash_clean_achieved(struct trash_clean *tclean) +{ + if (tclean->bytes_expunged < tclean->bytes_needed && + tclean->count_expunged < tclean->count_needed) + return FALSE; + return TRUE; +} + static int trash_clean_do_execute(struct trash_clean *tclean) { struct quota_transaction_context *ctx = tclean->ctx; @@ -223,8 +231,7 @@ static int trash_clean_do_execute(struct trash_clean *tclean) mail_expunge(tcboxes[oldest_idx].mail); tclean->count_expunged++; tclean->bytes_expunged += size; - if (tclean->bytes_expunged >= tclean->bytes_needed && - tclean->count_expunged >= tclean->count_needed) + if (trash_clean_achieved(tclean)) break; tcboxes[oldest_idx].mail = NULL; } else {