]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
trash: Perform check for achievement of quota usage reduction target in a separate...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 16 Nov 2018 14:18:20 +0000 (15:18 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Feb 2025 10:45:00 +0000 (10:45 +0000)
src/plugins/trash/trash-plugin.c

index 40a3ece20af542fcd2d2fd1bb905e84a7e6ed2a7..fe05be564eb92d3556d3889b29a6cfd9ebde44bc 100644 (file)
@@ -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 {