From 2c73b61d85e7c49bd7e020f4957e95a3e5cd2d04 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 13 Aug 2024 14:39:16 +0300 Subject: [PATCH] quota, trash: Move quota_settings.test_alloc() to struct quota --- src/plugins/quota/quota-private.h | 7 ++++--- src/plugins/quota/quota.c | 4 ++-- src/plugins/trash/trash-plugin.c | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/plugins/quota/quota-private.h b/src/plugins/quota/quota-private.h index 43fbdc0b37..7dbee0a220 100644 --- a/src/plugins/quota/quota-private.h +++ b/src/plugins/quota/quota-private.h @@ -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; diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index b0556b01cc..a1d9d84480 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -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("a->roots, 8); root_sets = array_get("a_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( diff --git a/src/plugins/trash/trash-plugin.c b/src/plugins/trash/trash-plugin.c index fc0dac88b2..e2d45c13a3 100644 --- a/src/plugins/trash/trash-plugin.c +++ b/src/plugins/trash/trash-plugin.c @@ -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; } } -- 2.47.3