]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Replace INDEXCACHE with mail_index_cache_path setting
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 27 Oct 2023 19:05:55 +0000 (22:05 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
src/lib-storage/list/mailbox-list-fs.c
src/lib-storage/list/mailbox-list-maildir.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 1bfd13d2f945ec14112d54f912998b2884ca6088..e08e3249e468e9ab4a70f4828d576dff01cfc7c8 100644 (file)
@@ -126,8 +126,9 @@ fs_list_get_path(struct mailbox_list *_list, const char *name,
                }
                break;
        case MAILBOX_LIST_PATH_TYPE_INDEX_CACHE:
-               if (set->index_cache_dir != NULL) {
-                       *path_r = fs_list_get_path_to(_list, set->index_cache_dir, name);
+               if (mail_set->mail_cache_path[0] != '\0') {
+                       *path_r = fs_list_get_path_to(_list,
+                               mail_set->mail_cache_path, name);
                        return 1;
                }
                /* fall through */
index a62ae361a497b552e23273bb97a3e93c6f15b059..9065c61910cfe2a98d1d2897e2e4390822578df5 100644 (file)
@@ -137,9 +137,9 @@ maildir_list_get_path(struct mailbox_list *_list, const char *name,
                }
                break;
        case MAILBOX_LIST_PATH_TYPE_INDEX_CACHE:
-               if (_list->set.index_cache_dir != NULL) {
+               if (_list->mail_set->mail_cache_path[0] != '\0') {
                        *path_r = maildir_list_get_dirname_path(_list,
-                                               _list->set.index_cache_dir, name);
+                               _list->mail_set->mail_cache_path, name);
                        return 1;
                }
                /* fall through */
index 915a8ef58dd72f172a71f9f7733bf41893ca2ecf..74a7cbec41d60fc47791c5b9b37b5150bd0071f1 100644 (file)
@@ -83,6 +83,7 @@ static const struct setting_define mail_storage_setting_defines[] = {
        DEF(BOOL_HIDDEN, mailbox_list_validate_fs_names),
        DEF(STR_HIDDEN, mailbox_root_directory_name),
        DEF(STR_HIDDEN, mailbox_subscriptions_filename),
+       DEF(STR_HIDDEN, mail_cache_path),
        DEF(STR, mail_control_path),
        DEF(STR, mail_volatile_path),
        DEF(STR, mail_alt_path),
@@ -154,6 +155,7 @@ const struct mail_storage_settings mail_storage_default_settings = {
        .mailbox_list_validate_fs_names = TRUE,
        .mailbox_root_directory_name = "",
        .mailbox_subscriptions_filename = "subscriptions",
+       .mail_cache_path = "",
        .mail_control_path = "",
        .mail_volatile_path = "",
        .mail_alt_path = "",
@@ -512,6 +514,7 @@ mailbox_list_get_path_setting(const char *key, const char **value,
                const char *set_name;
                enum mailbox_list_path_type type;
        } set_types[] = {
+               { "mail_cache_path", MAILBOX_LIST_PATH_TYPE_INDEX_CACHE },
                { "mail_control_path", MAILBOX_LIST_PATH_TYPE_CONTROL },
                { "mail_alt_path", MAILBOX_LIST_PATH_TYPE_ALT_DIR },
        };
@@ -1011,6 +1014,7 @@ static const size_t mail_storage_2nd_reset_offsets[] = {
        OFFSET(mailbox_list_iter_from_index_dir),
        OFFSET(mailbox_root_directory_name),
        OFFSET(mailbox_subscriptions_filename),
+       OFFSET(mail_cache_path),
        OFFSET(mail_control_path),
        OFFSET(mail_volatile_path),
        OFFSET(mail_alt_path),
index a6575bbca7b07e42acb96ce6b256426b9a10956d..41e17f9546115d44d91a336f109c17d7fefc181f 100644 (file)
@@ -63,6 +63,7 @@ struct mail_storage_settings {
        bool mailbox_list_validate_fs_names;
        const char *mailbox_root_directory_name;
        const char *mailbox_subscriptions_filename;
+       const char *mail_cache_path;
        const char *mail_control_path;
        const char *mail_volatile_path;
        const char *mail_alt_path;
index fa7a0c7bb72f3c112f64d89f3ecfbf908af60e7a..7408158061bb0a909c4385ae3ce1f7e68064fc29 100644 (file)
@@ -2171,8 +2171,10 @@ mailbox_lists_rename_compatible(struct mailbox_list *list1,
                        list1->ns->set->name, list2->ns->set->name);
                return FALSE;
        }
-       if (!nullequals(list1->set.index_cache_dir, list2->set.index_cache_dir)) {
-               *error_r = t_strdup_printf("Namespace %s has index cache dir, %s doesn't",
+       if (!nullequals(list1->mail_set->mail_cache_path,
+                       list2->mail_set->mail_cache_path)) {
+               *error_r = t_strdup_printf(
+                       "Namespace %s has mail_cache_path, %s doesn't",
                        list1->ns->set->name, list2->ns->set->name);
                return FALSE;
        }
index 3b9220c6d621491ece7ab0250931273d74895d9d..d9677d4339202a6c931f2700f4724365f3ea3416 100644 (file)
@@ -157,9 +157,6 @@ int mailbox_list_create(struct event *event, struct mail_namespace *ns,
                list->set.index_pvt_dir = set->index_pvt_dir == NULL ||
                        strcmp(set->index_pvt_dir, set->root_dir) == 0 ? NULL :
                        p_strdup(list->pool, set->index_pvt_dir);
-               list->set.index_cache_dir = set->index_cache_dir == NULL ||
-                       strcmp(set->index_cache_dir, set->root_dir) == 0 ? NULL :
-                       p_strdup(list->pool, set->index_cache_dir);
        }
 
        list->set.inbox_path = p_strdup(list->pool, set->inbox_path);
@@ -299,8 +296,6 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data,
                        dest = &set_r->index_dir;
                else if (strcmp(key, "INDEXPVT") == 0)
                        dest = &set_r->index_pvt_dir;
-               else if (strcmp(key, "INDEXCACHE") == 0)
-                       dest = &set_r->index_cache_dir;
                else if (strcmp(key, "DIRNAME") == 0)
                        dest = &set_r->maildir_name;
                else if (strcmp(key, "FULLDIRNAME") == 0) {
@@ -1408,12 +1403,7 @@ mailbox_list_set_get_root_path(const struct mailbox_list_settings *set,
        case MAILBOX_LIST_PATH_TYPE_LIST_INDEX:
                break;
        case MAILBOX_LIST_PATH_TYPE_INDEX_CACHE:
-               if (set->index_cache_dir != NULL &&
-                   type == MAILBOX_LIST_PATH_TYPE_INDEX_CACHE) {
-                       path = set->index_cache_dir;
-                       break;
-               }
-               /* fall through */
+               break;
        case MAILBOX_LIST_PATH_TYPE_INDEX:
                if (set->index_dir != NULL) {
                        if (set->index_dir[0] == '\0') {
@@ -1458,6 +1448,15 @@ bool mailbox_list_default_get_root_path(struct mailbox_list *list,
                path = mail_set->mail_control_path[0] != '\0' ?
                        mail_set->mail_control_path : list->set.root_dir;
                break;
+       case MAILBOX_LIST_PATH_TYPE_INDEX_CACHE:
+               if (mail_set->mail_cache_path[0] != '\0') {
+                       path = mail_set->mail_cache_path;
+                       break;
+               }
+               /* default to index directory */
+               return mailbox_list_set_get_root_path(&list->set,
+                       list->mail_set->parsed_mailbox_root_directory_prefix,
+                       MAILBOX_LIST_PATH_TYPE_INDEX, path_r);
        case MAILBOX_LIST_PATH_TYPE_LIST_INDEX:
                if (mail_set->parsed_list_index_dir != NULL) {
                        if (mail_set->parsed_list_index_dir[0] == '/') {
index 97fe432c8ac7a98261eb51384b2b49ac99a1efb9..446c7354235a17246fff77562bac0af899e04a3d 100644 (file)
@@ -117,7 +117,6 @@ struct mailbox_list_settings {
        const char *root_dir;
        const char *index_dir;
        const char *index_pvt_dir;
-       const char *index_cache_dir;
 
        const char *inbox_path;
        /* If non-empty, it means that mails exist in a maildir_name