]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota, trash: Move quota_settings.test_alloc() to struct quota
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 13 Aug 2024 11:39:16 +0000 (14:39 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:39:59 +0000 (10:39 +0200)
src/plugins/quota/quota-private.h
src/plugins/quota/quota.c
src/plugins/trash/trash-plugin.c

index 43fbdc0b376f2b2aa239f01aa61992657d845cdd..7dbee0a2201d8533c946dfb19bb40ab0df3ccce5 100644 (file)
@@ -17,15 +17,16 @@ struct quota {
        ARRAY(struct quota_root *) roots;
        ARRAY(struct mail_namespace *) namespaces;
        struct mail_namespace *unwanted_ns;
+
+       enum quota_alloc_result (*test_alloc)(
+               struct quota_transaction_context *ctx, uoff_t size,
+               const char **error_r);
 };
 
 struct quota_settings {
        pool_t pool;
 
        ARRAY(struct quota_root_settings *) root_sets;
-       enum quota_alloc_result (*test_alloc)(
-               struct quota_transaction_context *ctx, uoff_t size,
-               const char **error_r);
 
        unsigned int max_mailbox_count;
        uoff_t max_mail_size;
index b0556b01cc421a6d221a0c91fed406ad24d056ec..a1d9d844802b58ec2033ed89d8620248dc7e7dc7 100644 (file)
@@ -284,7 +284,6 @@ int quota_user_read_settings(struct mail_user *user,
        pool = pool_alloconly_create("quota settings", 2048);
        quota_set = p_new(pool, struct quota_settings, 1);
        quota_set->pool = pool;
-       quota_set->test_alloc = quota_default_test_alloc;
        quota_set->quota_exceeded_msg =
                mail_user_plugin_getenv(user, "quota_exceeded_message");
        if (quota_set->quota_exceeded_msg == NULL)
@@ -442,6 +441,7 @@ int quota_init(struct quota_settings *quota_set, struct mail_user *user,
        event_set_append_log_prefix(quota->event, "quota: ");
        quota->user = user;
        quota->set = quota_set;
+       quota->test_alloc = quota_default_test_alloc;
        i_array_init(&quota->roots, 8);
 
        root_sets = array_get(&quota_set->root_sets, &count);
@@ -1362,7 +1362,7 @@ enum quota_alloc_result quota_test_alloc(struct quota_transaction_context *ctx,
                return QUOTA_ALLOC_RESULT_OK;
        /* this is a virtual function mainly for trash plugin and similar,
           which may automatically delete mails to stay under quota. */
-       return ctx->quota->set->test_alloc(ctx, size, error_r);
+       return ctx->quota->test_alloc(ctx, size, error_r);
 }
 
 static enum quota_alloc_result quota_default_test_alloc(
index fc0dac88b2422d0dfd694e0cb0d475140301e04b..e2d45c13a323f772573b3c481ec4f72be05e7d9f 100644 (file)
@@ -375,8 +375,8 @@ trash_mail_namespaces_created(struct mail_namespace *namespaces)
        if (tuser != NULL && read_configuration(user, tuser->config_file) == 0) {
                i_assert(quser != NULL);
                trash_next_quota_test_alloc =
-                       quser->quota->set->test_alloc;
-               quser->quota->set->test_alloc = trash_quota_test_alloc;
+                       quser->quota->test_alloc;
+               quser->quota->test_alloc = trash_quota_test_alloc;
        }
 }