]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Check for namespaces' validity only once at mail_user init
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 22 Dec 2023 18:56:09 +0000 (13:56 -0500)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
There's no need to check them every time mail_storage_settings are looked
up.

src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h
src/lib-storage/mail-user.c

index 993c066b7ac39f9e027073e2a6b396a83e25b9d3..58e9224279584f6cb79071b2e84907fc43107231 100644 (file)
@@ -460,10 +460,9 @@ mail_storage_settings_find_ns(struct event *event,
        return 0;
 }
 
-static bool
-mail_storage_settings_check_namespaces(struct event *event,
-                                      struct mail_storage_settings *set,
-                                      const char **error_r)
+bool mail_storage_settings_check_namespaces(struct event *event,
+                                           struct mail_storage_settings *set,
+                                           const char **error_r)
 {
        const struct mail_namespace_settings *ns, *alias_ns;
        const char *ns_name, *error;
@@ -619,8 +618,8 @@ mail_storage_settings_apply(struct event *event ATTR_UNUSED, void *_set,
 }
 
 static bool
-mail_storage_settings_ext_check(struct event *event, void *_set, pool_t pool,
-                               const char **error_r)
+mail_storage_settings_ext_check(struct event *event ATTR_UNUSED,
+                               void *_set, pool_t pool, const char **error_r)
 {
        struct mail_storage_settings *set = _set;
        struct hash_format *format;
@@ -804,9 +803,6 @@ mail_storage_settings_ext_check(struct event *event, void *_set, pool_t pool,
                                set->mail_path, set->mail_inbox_path);
                }
        }
-
-       if (!mail_storage_settings_check_namespaces(event, set, error_r))
-               return FALSE;
        return TRUE;
 }
 
index 72d61ad684c85d77791f5f7dccf4cf130a542f24..be2bea850d992c2f36f2175c937cde86f5d027b9 100644 (file)
@@ -210,4 +210,8 @@ bool mail_user_set_get_postmaster_smtp(const struct mail_user_settings *set,
 void mail_storage_2nd_settings_reset(struct settings_instance *instance,
                                     const char *key_prefix);
 
+bool mail_storage_settings_check_namespaces(struct event *event,
+                                           struct mail_storage_settings *set,
+                                           const char **error_r);
+
 #endif
index deb287784313b5c6e80b28f4c827046c600abf0e..17dcea0f05d39458157a906e178ee62641f27012 100644 (file)
@@ -146,7 +146,9 @@ int mail_user_init(struct mail_user *user, const char **error_r)
        i_assert(!user->initialized);
 
        if (settings_get(user->event, &mail_storage_setting_parser_info, 0,
-                        &user->_mail_set, &error) < 0)
+                        &user->_mail_set, &error) < 0 ||
+           !mail_storage_settings_check_namespaces(user->event,
+                                                   user->_mail_set, &error))
                user->error = p_strdup(user->pool, error);
        else
                mail_user_expand_plugins_envs(user, user->_mail_set);