]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Make quota_alloc_with_size() directly suitable for moving/replacing messages
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 13 Feb 2025 01:25:18 +0000 (02:25 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Feb 2025 10:45:00 +0000 (10:45 +0000)
src/plugins/quota/quota.c

index 94b4186afc06fd27167a8a5e5b39b1b2917116a9..5034f583c553a21f64d5e0fa5cb27c4309a5881b 100644 (file)
@@ -1100,7 +1100,7 @@ void quota_transaction_rollback(struct quota_transaction_context **_ctx)
 }
 
 static void quota_alloc_with_size(struct quota_transaction_context *ctx,
-                                 uoff_t size)
+                                 uoff_t size, uoff_t expunged_size)
 {
        unsigned int i;
 
@@ -1109,6 +1109,10 @@ static void quota_alloc_with_size(struct quota_transaction_context *ctx,
        for (i = 0; i < array_count(&ctx->quota->all_roots); i++)
                ctx->roots[i].bytes_ceil = ctx->roots[i].bytes_ceil2;
        ctx->count_used++;
+
+       quota_used_apply_expunged(&ctx->bytes_used, expunged_size);
+       quota_used_apply_expunged(&ctx->count_used,
+                                 (expunged_size > 0 ? 1 : 0));
 }
 
 enum quota_alloc_result
@@ -1156,7 +1160,7 @@ quota_try_alloc(struct quota_transaction_context *ctx, struct mail *mail,
           quota_alloc() or quota_free_bytes() was already used within the same
           transaction, but that doesn't normally happen. */
        ctx->auto_updating = FALSE;
-       quota_alloc_with_size(ctx, size);
+       quota_alloc_with_size(ctx, size, 0);
        return QUOTA_ALLOC_RESULT_OK;
 }
 
@@ -1274,7 +1278,7 @@ void quota_alloc(struct quota_transaction_context *ctx, struct mail *mail)
                (void)quota_get_mail_size(ctx, mail, &size);
        }
 
-       quota_alloc_with_size(ctx, size);
+       quota_alloc_with_size(ctx, size, 0);
 }
 
 void quota_free_bytes(struct quota_transaction_context *ctx,