view->trans_seq2 < ctx->seq)
return 0;
/* check data still in memory. this works for recent mails
- even with INDEX=MEMORY */
+ even with mail_index_path=MEMORY */
if (!ctx->memory_appends_checked) {
if (mail_cache_lookup_iter_transaction(ctx))
return 1;
uint32_t seq, unsigned int field_idx);
/* Notify cache that the mail is now closed. Any records added with
mail_cache_add() are unlikely to be required again. This mainly tells
- INDEX=MEMORY that it can free up the memory used by the mail. */
+ mail_index_path=MEMORY that it can free up the memory used by the mail. */
void mail_cache_close_mail(struct mail_cache_transaction_ctx *ctx,
uint32_t seq);
int ret = -1;
bool has_log_in_index_dir = FALSE;
- if (box->list->set.index_dir != NULL) {
+ if (box->list->mail_set->mail_index_path[0] != '\0') {
/* Just because the index directory exists, it doesn't mean
that the mailbox is selectable. Check that by seeing if
dovecot.index.log exists. If it doesn't, fallback to
return 0;
}
- if (box->list->set.index_dir != NULL && existence_ret == 0) {
- /* If there is an separate INDEX directory configured but no
+ if (box->list->mail_set->mail_index_path[0] != '\0' &&
+ existence_ret == 0) {
+ /* If there is an separate mail_index_path configured but no
index files found for this mailbox, do an index rebuild */
if (sdbox_sync(mbox, SDBOX_SYNC_FLAG_FORCE_REBUILD) < 0)
return -1;
struct mailbox_list_settings list_set;
const char *error, *dir;
- dir = list->list.set.index_dir;
- if (dir == NULL)
+ if (list->list.mail_set->mail_index_path[0] == '\0')
dir = list->list.set.root_dir;
+ else if (strcmp(list->list.mail_set->mail_index_path,
+ MAIL_INDEX_PATH_MEMORY) == 0)
+ dir = "";
+ else
+ dir = list->list.mail_set->mail_index_path;
- if (dir == NULL || dir[0] == '\0') {
+ if (dir[0] == '\0') {
/* indexes disabled */
} else if (list->index_list == NULL && !list->index_list_failed) {
mailbox_list_settings_init_defaults(&list_set);
index_mail_close_streams_full(mail, TRUE);
/* Notify cache that the mail is no longer open. This mainly helps
- with INDEX=MEMORY to keep all data added with mail_cache_add() in
- memory until this point. */
+ with mail_index_path=MEMORY to keep all data added with
+ mail_cache_add() in memory until this point. */
mail_cache_close_mail(_mail->transaction->cache_trans, _mail->seq);
mailbox_header_lookup_unref(&mail->data.wanted_headers);
return pop3c_client_init(&client_set, storage->event);
}
-static void
-pop3c_storage_get_list_settings(const struct mail_namespace *ns ATTR_UNUSED,
- struct mailbox_list_settings *set,
- const struct mail_storage_settings *mail_set ATTR_UNUSED)
-{
- if (set->root_dir != NULL && *set->root_dir != '\0' &&
- set->index_dir == NULL) {
- /* we don't really care about root_dir, but we
- just need to get index_dir autocreated. */
- set->index_dir = set->root_dir;
- }
-}
-
static struct mailbox *
pop3c_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
const char *vname, enum mailbox_flags flags)
pop3c_storage_create,
pop3c_storage_destroy,
NULL,
- pop3c_storage_get_list_settings,
+ NULL,
NULL,
pop3c_mailbox_alloc,
NULL,
if (type == MAILBOX_LIST_PATH_TYPE_INDEX)
return TRUE;
- /* e.g. mail_control_path could point to the same INDEX dir. */
+ /* e.g. mail_control_path could point to the same as mail_index_path. */
type_root = mailbox_list_get_root_forced(list, type);
index_root = mailbox_list_get_root_forced(list, MAILBOX_LIST_PATH_TYPE_INDEX);
return strcmp(type_root, index_root) == 0;
mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_INDEX,
&index_path) > 0 &&
strcmp(index_path, path) == 0) {
- /* mail_control_path is the same as INDEX dir, which we already
- deleted. We don't want to continue especially with
+ /* mail_control_path is the same as mail_index_path, which we
+ already deleted. We don't want to continue especially with
mailbox_list_iter_from_index_dir=yes, because it could be
deleting the index directory. */
return 0;
}
/* Note that only mail_alt_path currently uses maildir_name in paths.
- INDEX and mail_control_path don't. */
+ mail_index_path and mail_control_path don't. */
if (type != MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX ||
*list->set.maildir_name == '\0') {
/* this directory may contain also child mailboxes' data.
int mailbox_list_delete_mailbox_nonrecursive(struct mailbox_list *list,
const char *name, const char *path,
bool rmdir_path);
-/* Lookup INDEX, mail_control_path and mail_alt_path directories for the
- mailbox and delete them.
+/* Lookup mail_index_path, mail_control_path and mail_alt_path directories
+ for the mailbox and delete them.
Returns 1 if anything was unlink()ed or rmdir()ed, 0 if not.
Returns -1 and sets the list error on any errors. */
int mailbox_list_delete_finish(struct mailbox_list *list, const char *name);
if (mailbox_list_try_get_absolute_path(_list, &name)) {
if (type == MAILBOX_LIST_PATH_TYPE_INDEX &&
- *set->index_dir == '\0')
+ strcmp(_list->mail_set->mail_index_path,
+ MAIL_INDEX_PATH_MEMORY) == 0)
return 0;
*path_r = name;
return 1;
}
/* fall through */
case MAILBOX_LIST_PATH_TYPE_INDEX:
- if (set->index_dir != NULL) {
- if (*set->index_dir == '\0')
+ if (mail_set->mail_index_path[0] != '\0') {
+ if (strcmp(mail_set->mail_index_path,
+ MAIL_INDEX_PATH_MEMORY) == 0)
return 0;
- *path_r = fs_list_get_path_to(_list, set->index_dir, name);
+ *path_r = fs_list_get_path_to(_list,
+ mail_set->mail_index_path, name);
return 1;
}
break;
'\0' : list->sep;
if (_list->mail_set->mailbox_list_iter_from_index_dir)
- ctx->dir = _list->set.index_dir;
+ ctx->dir = _list->mail_set->mail_index_path;
else
ctx->dir = _list->set.root_dir;
}
/* fall through */
case MAILBOX_LIST_PATH_TYPE_INDEX:
- if (_list->set.index_dir != NULL) {
- if (*_list->set.index_dir == '\0')
+ if (_list->mail_set->mail_index_path[0] != '\0') {
+ if (strcmp(_list->mail_set->mail_index_path,
+ MAIL_INDEX_PATH_MEMORY) == 0)
return 0;
*path_r = maildir_list_get_dirname_path(_list,
- _list->set.index_dir, name);
+ _list->mail_set->mail_index_path, name);
return 1;
}
break;
DEF(BOOL_HIDDEN, mailbox_list_validate_fs_names),
DEF(STR_HIDDEN, mailbox_root_directory_name),
DEF(STR_HIDDEN, mailbox_subscriptions_filename),
+ DEF(STR, mail_index_path),
DEF(STR, mail_index_private_path),
DEF(STR_HIDDEN, mail_cache_path),
DEF(STR, mail_control_path),
.mailbox_list_validate_fs_names = TRUE,
.mailbox_root_directory_name = "",
.mailbox_subscriptions_filename = "subscriptions",
+ .mail_index_path = "",
.mail_index_private_path = "",
.mail_cache_path = "",
.mail_control_path = "",
const char *set_name;
enum mailbox_list_path_type type;
} set_types[] = {
+ { "mail_index_path", MAILBOX_LIST_PATH_TYPE_INDEX },
{ "mail_index_private_path", MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE },
{ "mail_cache_path", MAILBOX_LIST_PATH_TYPE_INDEX_CACHE },
{ "mail_control_path", MAILBOX_LIST_PATH_TYPE_CONTROL },
set->parsed_list_index_dir =
p_strdup_until(pool, set->mailbox_list_index_prefix, fname);
set->parsed_list_index_fname = fname+1;
-#if 0 // FIXME: uncomment after mailbox_index_path is converted
if (set->parsed_list_index_dir[0] != '/' &&
- set->mailbox_index_path[0] == '\0') {
- *error_r = "mailbox_list_index_prefix directory is relative, but mailbox_index_path is empty";
+ set->mail_index_path[0] == '\0') {
+ *error_r = "mailbox_list_index_prefix directory is relative, but mail_index_path is empty";
return FALSE;
}
-#endif
}
if (set->mailbox_root_directory_name[0] == '\0')
set->parsed_mailbox_root_directory_prefix = "";
OFFSET(mailbox_list_iter_from_index_dir),
OFFSET(mailbox_root_directory_name),
OFFSET(mailbox_subscriptions_filename),
+ OFFSET(mail_index_path),
OFFSET(mail_index_private_path),
OFFSET(mail_cache_path),
OFFSET(mail_control_path),
#include "fsync-mode.h"
#include "mailbox-list.h"
+/* mail_index_path setting points to using in-memory indexes */
+#define MAIL_INDEX_PATH_MEMORY "MEMORY"
+
struct mail_user;
struct mail_namespace;
struct mail_storage;
bool mailbox_list_validate_fs_names;
const char *mailbox_root_directory_name;
const char *mailbox_subscriptions_filename;
+ const char *mail_index_path;
const char *mail_index_private_path;
const char *mail_cache_path;
const char *mail_control_path;
list1->ns->set->name, list2->ns->set->name);
return FALSE;
}
- if (!nullequals(list1->set.index_dir, list2->set.index_dir)) {
- *error_r = t_strdup_printf("Namespace %s has index dir, %s doesn't",
+ if (!nullequals(list1->mail_set->mail_index_path,
+ list2->mail_set->mail_index_path)) {
+ *error_r = t_strdup_printf(
+ "Namespace %s has mail_index_path, %s doesn't",
list1->ns->set->name, list2->ns->set->name);
return FALSE;
}
list->props |= MAILBOX_LIST_PROP_NO_NOSELECT;
/* copy settings */
- if (set->root_dir != NULL) {
+ if (set->root_dir != NULL)
list->set.root_dir = p_strdup(list->pool, set->root_dir);
- list->set.index_dir = set->index_dir == NULL ||
- strcmp(set->index_dir, set->root_dir) == 0 ? NULL :
- p_strdup(list->pool, set->index_dir);
- }
list->set.inbox_path = p_strdup(list->pool, set->inbox_path);
list->set.maildir_name =
"%s: root=%s, index=%s, indexpvt=%s, control=%s, inbox=%s, alt=%s",
list->name,
list->set.root_dir == NULL ? "" : list->set.root_dir,
- list->set.index_dir == NULL ? "" : list->set.index_dir,
+ mail_set->mail_index_path,
mail_set->mail_index_private_path,
mail_set->mail_control_path,
list->set.inbox_path == NULL ?
if (strcmp(key, "INBOX") == 0)
dest = &set_r->inbox_path;
- else if (strcmp(key, "INDEX") == 0)
- dest = &set_r->index_dir;
else if (strcmp(key, "DIRNAME") == 0)
dest = &set_r->maildir_name;
else if (strcmp(key, "FULLDIRNAME") == 0) {
return -1;
}
}
-
- if (set_r->index_dir != NULL && strcmp(set_r->index_dir, "MEMORY") == 0)
- set_r->index_dir = "";
return 0;
}
case MAILBOX_LIST_PATH_TYPE_CONTROL:
type = MAILBOX_LIST_PATH_TYPE_DIR;
break;
+ case MAILBOX_LIST_PATH_TYPE_INDEX:
+ type = MAILBOX_LIST_PATH_TYPE_DIR;
+ break;
case MAILBOX_LIST_PATH_TYPE_LIST_INDEX:
type = MAILBOX_LIST_PATH_TYPE_INDEX;
break;
case MAILBOX_LIST_PATH_TYPE_INDEX_CACHE:
break;
case MAILBOX_LIST_PATH_TYPE_INDEX:
- if (set->index_dir != NULL) {
- if (set->index_dir[0] == '\0') {
- /* in-memory indexes */
- return 0;
- }
- path = set->index_dir;
- } else {
- path = set->root_dir;
- }
break;
case MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE:
break;
path = mail_set->mail_control_path[0] != '\0' ?
mail_set->mail_control_path : list->set.root_dir;
break;
+ case MAILBOX_LIST_PATH_TYPE_INDEX:
+ if (mail_set->mail_index_path[0] != '\0') {
+ if (strcmp(mail_set->mail_index_path,
+ MAIL_INDEX_PATH_MEMORY) == 0) {
+ /* in-memory indexes */
+ return 0;
+ }
+ path = mail_set->mail_index_path;
+ } else {
+ path = list->set.root_dir;
+ }
+ break;
case MAILBOX_LIST_PATH_TYPE_INDEX_PRIVATE:
path = mail_set->mail_index_private_path;
break;
break;
}
/* default to index directory */
- return mailbox_list_set_get_root_path(&list->set,
- list->mail_set->parsed_mailbox_root_directory_prefix,
+ return mailbox_list_default_get_root_path(list,
MAILBOX_LIST_PATH_TYPE_INDEX, path_r);
case MAILBOX_LIST_PATH_TYPE_LIST_INDEX:
if (mail_set->parsed_list_index_dir != NULL) {
break;
}
/* relative path */
- if (!mailbox_list_set_get_root_path(&list->set,
- list->mail_set->parsed_mailbox_root_directory_prefix,
+ if (!mailbox_list_default_get_root_path(list,
MAILBOX_LIST_PATH_TYPE_INDEX, &path))
i_unreached();
path = t_strconcat(path, "/",
mail_set->parsed_list_index_dir, NULL);
}
/* default to index directory */
- return mailbox_list_set_get_root_path(&list->set,
- list->mail_set->parsed_mailbox_root_directory_prefix,
+ return mailbox_list_default_get_root_path(list,
MAILBOX_LIST_PATH_TYPE_INDEX, path_r);
default:
return mailbox_list_set_get_root_path(&list->set,
struct mailbox_list_settings {
const char *root_dir;
- const char *index_dir;
const char *inbox_path;
/* If non-empty, it means that mails exist in a maildir_name