Skip to content

Commit

Permalink
lib-storage: Make sure index root is created when it's the same as ro…
Browse files Browse the repository at this point in the history
…ot directory

Fixes errors about failing to create mailboxes.lock when the index root
directory doesn't exist yet.
  • Loading branch information
sirainen committed May 3, 2018
1 parent b8066fc commit 27366c1
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/lib-storage/mailbox-list.c
Expand Up @@ -1653,27 +1653,23 @@ static bool mailbox_list_init_changelog(struct mailbox_list *list)

int mailbox_list_mkdir_missing_index_root(struct mailbox_list *list)
{
const char *root_dir, *index_dir;
const char *index_dir;
int ret;

if (list->index_root_dir_created)
return 1;

/* if index root dir hasn't been created yet, do it now */
/* If index root dir hasn't been created yet, do it now.
Do this here even if the index directory is the same as mail root
directory, because it may not have been created elsewhere either. */
ret = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_INDEX,
&index_dir);
if (ret <= 0)
return ret;
ret = mailbox_list_get_root_path(list, MAILBOX_LIST_PATH_TYPE_MAILBOX,
&root_dir);
if (ret <= 0)
return ret;

if (strcmp(root_dir, index_dir) != 0) {
if (mailbox_list_mkdir_root(list, index_dir,
MAILBOX_LIST_PATH_TYPE_INDEX) < 0)
return -1;
}
if (mailbox_list_mkdir_root(list, index_dir,
MAILBOX_LIST_PATH_TYPE_INDEX) < 0)
return -1;
list->index_root_dir_created = TRUE;
return 1;
}
Expand Down

0 comments on commit 27366c1

Please sign in to comment.