]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Replace ITERINDEX with mailbox_list_iter_from_index_dir setting
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 26 Oct 2023 10:06:51 +0000 (13:06 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:10 +0000 (12:34 +0200)
This removes the check that INDEX must also be set. It's not really
necessary, the setting's value just gets ignored then.

12 files changed:
src/lib-storage/index/dbox-common/dbox-storage.c
src/lib-storage/index/index-storage.c
src/lib-storage/list/mailbox-list-delete.c
src/lib-storage/list/mailbox-list-fs-flags.c
src/lib-storage/list/mailbox-list-fs-iter.c
src/lib-storage/list/mailbox-list-fs.c
src/lib-storage/list/mailbox-list-maildir-iter.c
src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list.c
src/lib-storage/mailbox-list.h

index a01ad0423ac7569dbc05f203c3c6a9115b88c14a..757e629c0b33d7793d7adc3cf675e1f0656c1271 100644 (file)
@@ -255,7 +255,8 @@ int dbox_mailbox_check_existence(struct mailbox *box)
        }
        if (ret < 0) {
                ret = stat(box_path, &st);
-       } else if (ret == 0 && !box->list->set.iter_from_index_dir &&
+       } else if (ret == 0 &&
+                  !box->list->mail_set->mailbox_list_iter_from_index_dir &&
                   *box->list->set.mailbox_dir_name == '\0') {
                /* There are index files for this mailbox and no separate
                mailboxes directory is configured. */
index b587b76f0cb1c3a49053f6801457ab4c8f087485..c88b7566bf55be051aa525155ba4f61999cee7d7 100644 (file)
@@ -216,7 +216,8 @@ int index_storage_mailbox_exists_full(struct mailbox *box, const char *subdir,
                return 0;
        }
 
-       ret = (subdir != NULL || !box->list->set.iter_from_index_dir) ? 0 :
+       ret = (subdir != NULL ||
+              !box->list->mail_set->mailbox_list_iter_from_index_dir) ? 0 :
                mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &index_path);
        if (ret > 0 && strcmp(path, index_path) != 0) {
                /* index directory is different - prefer looking it up first
@@ -660,7 +661,7 @@ int index_storage_mailbox_create(struct mailbox *box, bool directory)
 
        if ((ret = mailbox_mkdir(box, path, type)) < 0)
                return -1;
-       if (box->list->set.iter_from_index_dir) {
+       if (box->list->mail_set->mailbox_list_iter_from_index_dir) {
                /* need to also create the directory to index path or
                   iteration won't find it. */
                int ret2;
@@ -1286,10 +1287,11 @@ int index_mailbox_fix_inconsistent_existence(struct mailbox *box,
        const char *index_path;
        struct stat st;
 
-       /* Could be a race condition or could be because ITERINDEX is used
-          and the index directory exists, but the storage directory doesn't.
-          Handle the existence inconsistency by creating this directory if
-          the index directory exists (don't bother checking if ITERINDEX is
+       /* Could be a race condition or could be because
+          mailbox_list_iter_from_index_dir=yes is used and the index directory
+          exists, but the storage directory doesn't. Handle the existence
+          inconsistency by creating this directory if the index directory
+          exists (don't bother checking if mailbox_list_iter_from_index_dir is
           set or not - it doesn't matter since either both dirs should exist
           or not). */
        if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX,
index d62993345a4fbd1b36d8474534e0ebe4cf9d93b8..b092a0ac74bdffc8cbe24d17e0edf03a1a3965e5 100644 (file)
@@ -278,10 +278,11 @@ void mailbox_list_delete_until_root(struct mailbox_list *list, const char *path,
        const char *root_dir, *p;
        size_t len;
 
-       if (list->set.iter_from_index_dir &&
+       if (list->mail_set->mailbox_list_iter_from_index_dir &&
            !list->mail_set->mailbox_list_drop_noselect &&
            mailbox_list_path_is_index(list, type)) {
-               /* Don't auto-rmdir parent index directories with ITERINDEX.
+               /* Don't auto-rmdir parent index directories with
+                  mailbox_list_iter_from_index_dir=yes.
                   Otherwise it'll get us into inconsistent state with a
                   \NoSelect mailbox in the mail directory but not in index
                   directory. */
@@ -360,8 +361,8 @@ static int mailbox_list_try_delete(struct mailbox_list *list, const char *name,
            strcmp(index_path, path) == 0) {
                /* CONTROL dir is the same as INDEX dir, which we already
                   deleted. We don't want to continue especially with
-                  iter_from_index_dir=yes, because it could be deleting the
-                  index directory. */
+                  mailbox_list_iter_from_index_dir=yes, because it could be
+                  deleting the index directory. */
                return 0;
        }
 
index ed05f6b2e26deb0473c14915b1d76d26484e2bce..55be72f054010747c861144f00f07b48cf9a5d02 100644 (file)
@@ -118,7 +118,8 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list,
 
        *flags_r = 0;
 
-       if (*list->set.maildir_name != '\0' && !list->set.iter_from_index_dir) {
+       if (*list->set.maildir_name != '\0' &&
+           !list->mail_set->mailbox_list_iter_from_index_dir) {
                /* maildir_name is set: This is the simple case that works for
                   all mail storage formats, because the only thing that
                   matters for existence or child checks is whether the
@@ -136,7 +137,7 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list,
           though maildir_name is set, it's not used for index directory.
        */
 
-       if (!list->set.iter_from_index_dir &&
+       if (!list->mail_set->mailbox_list_iter_from_index_dir &&
            list->v.is_internal_name != NULL &&
            list->v.is_internal_name(list, fname)) {
                /* skip internal dirs. For example Maildir's cur/new/tmp */
@@ -224,7 +225,8 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list,
                return 1;
        }
 
-       if (list->v.is_internal_name == NULL || list->set.iter_from_index_dir) {
+       if (list->v.is_internal_name == NULL ||
+           list->mail_set->mailbox_list_iter_from_index_dir) {
                /* This mailbox format doesn't use any special directories
                   (e.g. Maildir's cur/new/tmp). In that case we can look at
                   the directory's link count to determine whether there are
index 8524d7c4cebb92b20ddd1d36d381193bcf8fac7b..c594a042c26c2cc36cf84ecd112f1a8917dddf14 100644 (file)
@@ -532,7 +532,8 @@ fs_list_iter_init(struct mailbox_list *_list, const char *const *patterns,
        ctx->info_pool = pool_alloconly_create("fs list", 1024);
        ctx->sep = mail_namespace_get_sep(_list->ns);
        ctx->info.ns = _list->ns;
-       ctx->ctx.iter_from_index_dir = ctx->ctx.list->set.iter_from_index_dir;
+       ctx->ctx.iter_from_index_dir =
+               ctx->ctx.list->mail_set->mailbox_list_iter_from_index_dir;
 
        if ((flags & MAILBOX_LIST_ITER_FORCE_RESYNC) != 0) {
                i_assert(!hash_table_is_created(ctx->ctx.found_mailboxes));
index 2e1c0d1eb0107c7faf871d17ed3e0e0e1bd97b39..077fe1a2dfa03c5f035ede76f0a9f0895db246f3 100644 (file)
@@ -304,7 +304,7 @@ static int fs_list_delete_dir(struct mailbox_list *list, const char *name)
                                  &path) <= 0)
                i_unreached();
        ret = fs_list_rmdir(list, name, path);
-       if (!list->set.iter_from_index_dir) {
+       if (!list->mail_set->mailbox_list_iter_from_index_dir) {
                /* it should exist only in the mail directory */
                if (ret == 0)
                        return 0;
index c7108c6739d84c76ba9351608b91704915bb0348..7cafac1f3e5c53a13ecfa9ac7dc1492319578bae 100644 (file)
@@ -443,7 +443,7 @@ maildir_list_iter_init(struct mailbox_list *_list, const char *const *patterns,
        ctx->prefix_char = strcmp(_list->name, MAILBOX_LIST_NAME_IMAPDIR) == 0 ?
                '\0' : list->sep;
 
-       if (_list->set.iter_from_index_dir)
+       if (_list->mail_set->mailbox_list_iter_from_index_dir)
                ctx->dir = _list->set.index_dir;
        else
                ctx->dir = _list->set.root_dir;
index a04d60f00e490b000a9a0968a17a827ea9affed9..1ade2fe49fad9972bdcfe3139d2835885a8e2a4c 100644 (file)
@@ -76,6 +76,7 @@ static const struct setting_define mail_storage_setting_defines[] = {
        DEF(BOOL, mailbox_list_index),
        DEF(BOOL, mailbox_list_index_very_dirty_syncs),
        DEF(BOOL, mailbox_list_index_include_inbox),
+       DEF(BOOL_HIDDEN, mailbox_list_iter_from_index_dir),
        DEF(BOOL_HIDDEN, mailbox_list_drop_noselect),
        DEF(BOOL_HIDDEN, mailbox_list_validate_fs_names),
        DEF(BOOL_HIDDEN, mail_full_filesystem_access),
@@ -138,6 +139,7 @@ const struct mail_storage_settings mail_storage_default_settings = {
        .mailbox_list_index = TRUE,
        .mailbox_list_index_very_dirty_syncs = FALSE,
        .mailbox_list_index_include_inbox = FALSE,
+       .mailbox_list_iter_from_index_dir = FALSE,
        .mailbox_list_drop_noselect = TRUE,
        .mailbox_list_validate_fs_names = TRUE,
        .mail_full_filesystem_access = FALSE,
@@ -925,6 +927,7 @@ bool mail_user_set_get_postmaster_smtp(const struct mail_user_settings *set,
 #define OFFSET(name) offsetof(struct mail_storage_settings, name)
 static const size_t mail_storage_2nd_reset_offsets[] = {
        OFFSET(mail_location),
+       OFFSET(mailbox_list_iter_from_index_dir),
 };
 
 static void
index 7e98f1d85622cd122e25c9ebd0a978462e7c7b08..029a88593d630cd98c1ae4d8993fe4b6bd06ab82 100644 (file)
@@ -55,6 +55,7 @@ struct mail_storage_settings {
        bool mailbox_list_index;
        bool mailbox_list_index_very_dirty_syncs;
        bool mailbox_list_index_include_inbox;
+       bool mailbox_list_iter_from_index_dir;
        bool mailbox_list_drop_noselect;
        bool mailbox_list_validate_fs_names;
        bool mail_full_filesystem_access;
index b9169ab98a075e88ada32a1a666d5e964c4252a4..dc25ca884b11f42c7c024ff755b3f74c4122a481 100644 (file)
@@ -280,7 +280,7 @@ mail_storage_create_root(struct mailbox_list *list,
        const char *root_dir, *type_name, *error;
        enum mailbox_list_path_type type;
 
-       if (list->set.iter_from_index_dir) {
+       if (list->mail_set->mailbox_list_iter_from_index_dir) {
                type = MAILBOX_LIST_PATH_TYPE_INDEX;
                type_name = "index";
        } else {
index aecce65aedff110e70c5389a745ea5ad38d77ad6..d3def28a61138acbaaa51e4b060422e7e2a12c6e 100644 (file)
@@ -189,7 +189,6 @@ int mailbox_list_create(const char *driver, struct event *event,
        list->set.volatile_dir = p_strdup(list->pool, set->volatile_dir);
        list->set.index_control_use_maildir_name =
                set->index_control_use_maildir_name;
-       list->set.iter_from_index_dir = set->iter_from_index_dir;
 
        if (*set->mailbox_dir_name == '\0')
                list->set.mailbox_dir_name = "";
@@ -365,9 +364,6 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data,
                        }
                        set_r->vname_escape_char = value[0];
                        continue;
-               } else if (strcmp(key, "ITERINDEX") == 0) {
-                       set_r->iter_from_index_dir = TRUE;
-                       continue;
                } else {
                        *error_r = t_strdup_printf("Unknown setting: %s", key);
                        return -1;
@@ -380,11 +376,6 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data,
 
        if (set_r->index_dir != NULL && strcmp(set_r->index_dir, "MEMORY") == 0)
                set_r->index_dir = "";
-       if (set_r->iter_from_index_dir &&
-           (set_r->index_dir == NULL || set_r->index_dir[0] == '\0')) {
-               *error_r = "ITERINDEX requires INDEX to be explicitly set";
-               return -1;
-       }
        if (set_r->list_index_fname != NULL &&
            (fname = strrchr(set_r->list_index_fname, '/')) != NULL) {
                /* non-default LISTINDEX directory */
@@ -1014,7 +1005,7 @@ mailbox_list_get_permissions_internal(struct mailbox_list *list,
        permissions_r->file_create_gid = (gid_t)-1;
        permissions_r->file_create_gid_origin = "defaults";
 
-       if (list->set.iter_from_index_dir ||
+       if (list->mail_set->mailbox_list_iter_from_index_dir ||
            (list->flags & MAILBOX_LIST_FLAG_NO_MAIL_FILES) != 0) {
                /* a) iterating from index dir. Use the index dir's permissions
                   as well, since they might be in a faster storage.
@@ -1600,7 +1591,7 @@ int mailbox_list_mailbox(struct mailbox_list *list, const char *name,
                return mailbox_list_iter_deinit(&iter);
        }
 
-       if (!list->set.iter_from_index_dir) {
+       if (!list->mail_set->mailbox_list_iter_from_index_dir) {
                rootdir = mailbox_list_get_root_forced(list, MAILBOX_LIST_PATH_TYPE_MAILBOX);
                if (mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_DIR, &path) <= 0)
                        i_unreached();
index c1884d29180fe37c744c33fc3b3f82a9d626677c..689eb4d833fc578502edc5ec7f5f16eabe9582cf 100644 (file)
@@ -175,11 +175,6 @@ struct mailbox_list_settings {
           have been the default since the beginning, but for backwards
           compatibility it had to be made an option. */
        bool index_control_use_maildir_name:1;
-       /* Perform mailbox iteration using the index directory instead of the
-          mail root directory. This can be helpful if the indexes are on a
-          faster storage. This could perhaps be made the default at some point,
-          but for now since it's less tested it's optional. */
-       bool iter_from_index_dir:1;
 };
 
 struct mailbox_permissions {