]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Use parsed_mailboxes instead of getting mailbox settings again
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 6 Mar 2025 18:30:48 +0000 (20:30 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Mar 2025 13:01:57 +0000 (13:01 +0000)
src/lib-storage/list/mailbox-list-iter.c
src/lib-storage/mail-autoexpunge.c

index e15a79f3f2fc75b31628ce5c28398baa5d3cbeb1..966c1140c89ea3cab414c94874c53768003f4203 100644 (file)
@@ -102,15 +102,9 @@ mailbox_list_iter_init_autocreate(struct mailbox_list_iterate_context *ctx)
        struct mail_namespace *ns = ctx->list->ns;
        struct mailbox_list_autocreate_iterate_context *actx;
        const struct mailbox_settings *box_set, *set;
-       const char *error, *const *box_names;
        struct autocreate_box *autobox;
-       unsigned int i, count;
-
-       if (!array_is_created(&ns->set->mailboxes))
-               return 0;
 
-       box_names = array_get(&ns->set->mailboxes, &count);
-       if (count == 0)
+       if (array_is_empty(&ns->set->parsed_mailboxes))
                return 0;
 
        actx = p_new(ctx->pool, struct mailbox_list_autocreate_iterate_context, 1);
@@ -122,25 +116,15 @@ mailbox_list_iter_init_autocreate(struct mailbox_list_iterate_context *ctx)
        p_array_init(&actx->boxes, ctx->pool, 16);
        p_array_init(&actx->box_sets, ctx->pool, 16);
        p_array_init(&actx->all_ns_box_sets, ctx->pool, 16);
-       for (i = 0; i < count; i++) {
-               if (settings_get_filter(ns->list->event,
-                                       "mailbox", box_names[i],
-                                       &mailbox_setting_parser_info, 0,
-                                       &box_set, &error) < 0) {
-                       mailbox_list_set_critical(ctx->list, "%s", error);
-                       return -1;
-               }
-               if (strcmp(box_set->autocreate, MAILBOX_SET_AUTO_NO) == 0) {
-                       settings_free(box_set);
+       array_foreach_elem(&ns->set->parsed_mailboxes, box_set) {
+               if (strcmp(box_set->autocreate, MAILBOX_SET_AUTO_NO) == 0)
                        continue;
-               }
 
                set = mailbox_settings_add_ns_prefix(ctx->pool, ns, box_set);
 
                /* autocreate mailbox belongs to listed namespace */
                array_push_back(&actx->all_ns_box_sets, &set);
                pool_add_external_ref(ctx->pool, box_set->pool);
-               settings_free(box_set);
                if ((ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0 ||
                    strcmp(set->autocreate, MAILBOX_SET_AUTO_SUBSCRIBE) == 0) {
                        array_push_back(&actx->box_sets, &set);
index 4f36d607fc7aef34374768a3c898f73dd1310c82..245318564e249edb619897ba99586b0305565964 100644 (file)
@@ -239,31 +239,20 @@ mail_namespace_autoexpunge(struct mail_namespace *ns, struct file_lock **lock,
                           unsigned int *expunged_count)
 {
        const struct mailbox_settings *box_set;
-       const char *box_name, *error;
 
-       if (!array_is_created(&ns->set->mailboxes))
+       if (!array_is_created(&ns->set->parsed_mailboxes))
                return TRUE;
 
-       array_foreach_elem(&ns->set->mailboxes, box_name) {
-               if (settings_get_filter(mailbox_list_get_event(ns->list),
-                                       "mailbox", box_name,
-                                       &mailbox_setting_parser_info, 0,
-                                       &box_set, &error) < 0) {
-                       e_error(mailbox_list_get_event(ns->list), "%s", error);
-                       break;
-               }
-
+       array_foreach_elem(&ns->set->parsed_mailboxes, box_set) {
                if (box_set->autoexpunge == 0 &&
                    box_set->autoexpunge_max_mails == 0) {
                        /* no autoexpunging needed */
                } else if (!mailbox_autoexpunge_lock(ns->user, lock)) {
                        /* another process is already autoexpunging */
-                       settings_free(box_set);
                        return FALSE;
                } else T_BEGIN {
                        mailbox_autoexpunge_name(ns, box_set, expunged_count);
                } T_END;
-               settings_free(box_set);
        }
        return TRUE;
 }