Mercurial > dovecot > core-2.2
changeset 13652:7e1981ecbe40
imapc: Don't use separate indexes/ directory anymore. Fixes/cleanups to make it possible.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 04 Nov 2011 21:20:19 +0200 |
parents | ebdb1d51ea14 |
children | 0103b917fa0c |
files | src/lib-storage/index/imapc/imapc-list.c src/lib-storage/index/imapc/imapc-storage.c src/lib-storage/index/imapc/imapc-storage.h src/lib-storage/list/mailbox-list-fs.c src/lib-storage/list/mailbox-list-maildir.c src/lib-storage/mailbox-list.c src/lib-storage/mailbox-list.h |
diffstat | 7 files changed, 31 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-list.c Fri Nov 04 21:17:09 2011 +0200 +++ b/src/lib-storage/index/imapc/imapc-list.c Fri Nov 04 21:20:19 2011 +0200 @@ -205,16 +205,11 @@ } else if (list->index_list == NULL && !list->index_list_failed) { memset(&list_set, 0, sizeof(list_set)); list_set.layout = MAILBOX_LIST_NAME_MAILDIRPLUSPLUS; - /* the root dir shouldn't actually ever be used. we just need - it to be different from index_dir so the index directories - get autocreated */ list_set.root_dir = dir; - list_set.index_dir = t_strconcat(dir, "/indexes", NULL); - list_set.escape_char = '%'; + list_set.escape_char = IMAPC_LIST_ESCAPE_CHAR; if (mailbox_list_create(list_set.layout, list->list.ns, - &list_set, MAILBOX_LIST_FLAG_SECONDARY | - MAILBOX_LIST_FLAG_OPTIONAL_BOXES, + &list_set, MAILBOX_LIST_FLAG_SECONDARY, &list->index_list, &error) < 0) { i_error("imapc: Couldn't create %s mailbox list: %s", list_set.layout, error); @@ -589,16 +584,18 @@ i_assert(list->sep != '\0'); vname = mailbox_list_default_get_vname(_list, name); - node = mailbox_tree_lookup(list->mailboxes, vname); - if (node != NULL) - node->flags |= MAILBOX_NONEXISTENT; + if (!list->refreshed_mailboxes) { + node = mailbox_tree_lookup(list->mailboxes, vname); + if (node != NULL) + node->flags |= MAILBOX_NONEXISTENT; - /* refresh the mailbox flags */ - cmd = imapc_list_simple_context_init(&sctx, list); - imapc_command_sendf(cmd, "LIST \"\" %s", name); - imapc_simple_run(&sctx); - if (sctx.ret < 0) - return -1; + /* refresh the mailbox flags */ + cmd = imapc_list_simple_context_init(&sctx, list); + imapc_command_sendf(cmd, "LIST \"\" %s", name); + imapc_simple_run(&sctx); + if (sctx.ret < 0) + return -1; + } node = mailbox_tree_lookup(list->mailboxes, vname); if (node == NULL) @@ -610,7 +607,7 @@ struct mailbox_list imapc_mailbox_list = { .name = MAILBOX_LIST_NAME_IMAPC, - .props = MAILBOX_LIST_PROP_NO_ROOT, + .props = MAILBOX_LIST_PROP_NO_ROOT | MAILBOX_LIST_PROP_AUTOCREATE_DIRS, .mailbox_name_max_length = MAILBOX_LIST_NAME_MAX_LENGTH, {
--- a/src/lib-storage/index/imapc/imapc-storage.c Fri Nov 04 21:17:09 2011 +0200 +++ b/src/lib-storage/index/imapc/imapc-storage.c Fri Nov 04 21:20:19 2011 +0200 @@ -288,6 +288,7 @@ struct mailbox_list_settings *set) { set->layout = MAILBOX_LIST_NAME_IMAPC; + set->escape_char = IMAPC_LIST_ESCAPE_CHAR; } static struct mailbox *
--- a/src/lib-storage/index/imapc/imapc-storage.h Fri Nov 04 21:17:09 2011 +0200 +++ b/src/lib-storage/index/imapc/imapc-storage.h Fri Nov 04 21:20:19 2011 +0200 @@ -5,6 +5,7 @@ #define IMAPC_STORAGE_NAME "imapc" #define IMAPC_INDEX_PREFIX "dovecot.index" +#define IMAPC_LIST_ESCAPE_CHAR '%' struct imap_arg; struct imapc_untagged_reply;
--- a/src/lib-storage/list/mailbox-list-fs.c Fri Nov 04 21:17:09 2011 +0200 +++ b/src/lib-storage/list/mailbox-list-fs.c Fri Nov 04 21:20:19 2011 +0200 @@ -361,7 +361,7 @@ ret = fs_list_delete_maildir(list, name); } - if (ret == 0 || (list->flags & MAILBOX_LIST_FLAG_OPTIONAL_BOXES) != 0) + if (ret == 0 || (list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) != 0) mailbox_list_delete_finish(list, name); return ret; }
--- a/src/lib-storage/list/mailbox-list-maildir.c Fri Nov 04 21:17:09 2011 +0200 +++ b/src/lib-storage/list/mailbox-list-maildir.c Fri Nov 04 21:20:19 2011 +0200 @@ -410,7 +410,7 @@ ret = maildir_list_delete_maildir(list, name); } - if (ret == 0 || (list->flags & MAILBOX_LIST_FLAG_OPTIONAL_BOXES) != 0) + if (ret == 0 || (list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) != 0) mailbox_list_delete_finish(list, name); return ret; }
--- a/src/lib-storage/mailbox-list.c Fri Nov 04 21:17:09 2011 +0200 +++ b/src/lib-storage/mailbox-list.c Fri Nov 04 21:20:19 2011 +0200 @@ -1307,7 +1307,9 @@ enum mailbox_existence existence; int ret; - box = mailbox_alloc(list, "INBOX", 0); + /* kludge: with imapc backend we can get here with + list=Maildir++ (for indexes), but list->ns->list=imapc */ + box = mailbox_alloc(list->ns->list, "INBOX", 0); ret = mailbox_exists(box, FALSE, &existence); mailbox_free(&box); if (ret < 0) { @@ -1730,8 +1732,13 @@ MAILBOX_LIST_PATH_TYPE_MAILBOX); index_dir = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_INDEX); - if (*index_dir == '\0' || strcmp(index_dir, root_dir) == 0) + if (*index_dir == '\0') return 0; + if (strcmp(index_dir, root_dir) == 0) { + if ((list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) == 0) + return 0; + /* the directory might not have been created yet */ + } if (name == NULL) { return mailbox_list_mkdir_root(list, index_dir,
--- a/src/lib-storage/mailbox-list.h Fri Nov 04 21:17:09 2011 +0200 +++ b/src/lib-storage/mailbox-list.h Fri Nov 04 21:20:19 2011 +0200 @@ -24,7 +24,9 @@ /* no support for \noselect directories, only mailboxes */ MAILBOX_LIST_PROP_NO_NOSELECT = 0x04, /* mail root directory isn't required */ - MAILBOX_LIST_PROP_NO_ROOT = 0x08 + MAILBOX_LIST_PROP_NO_ROOT = 0x08, + /* Automatically create mailbox directories when needed */ + MAILBOX_LIST_PROP_AUTOCREATE_DIRS = 0x10 }; enum mailbox_list_flags { @@ -32,11 +34,7 @@ MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x01, /* Namespace already has a mailbox list, don't assign this mailbox list to it. */ - MAILBOX_LIST_FLAG_SECONDARY = 0x02, - /* Don't assume that just because a mailbox directory doesn't exist - its index/control directories don't exist (e.g. this is index-only - mailbox list) */ - MAILBOX_LIST_FLAG_OPTIONAL_BOXES = 0x04 + MAILBOX_LIST_FLAG_SECONDARY = 0x02 }; enum mailbox_info_flags {