Skip to content

Commit

Permalink
sdbox: Don't create index directory when trying to open nonexistent m…
Browse files Browse the repository at this point in the history
…ailboxes
  • Loading branch information
sirainen committed Jul 3, 2017
1 parent 1399662 commit ea4d545
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib-storage/index/dbox-common/dbox-storage.c
Expand Up @@ -190,7 +190,7 @@ dbox_cleanup_if_exists(struct mailbox_list *list, const char *path)
return TRUE;
}

int dbox_mailbox_open(struct mailbox *box)
int dbox_mailbox_check_existence(struct mailbox *box)
{
const char *box_path = mailbox_get_path(box);

Expand All @@ -209,7 +209,11 @@ int dbox_mailbox_open(struct mailbox *box)
"stat(%s) failed: %m", box_path);
return -1;
}
return 0;
}

int dbox_mailbox_open(struct mailbox *box)
{
if (index_storage_mailbox_open(box, FALSE) < 0)
return -1;
mail_index_set_fsync_mode(box->index,
Expand Down
1 change: 1 addition & 0 deletions src/lib-storage/index/dbox-common/dbox-storage.h
Expand Up @@ -70,6 +70,7 @@ int dbox_storage_create(struct mail_storage *storage,
void dbox_storage_destroy(struct mail_storage *storage);
uint32_t dbox_get_uidvalidity_next(struct mailbox_list *list);
void dbox_notify_changes(struct mailbox *box);
int dbox_mailbox_check_existence(struct mailbox *box);
int dbox_mailbox_open(struct mailbox *box);
int dbox_mailbox_create(struct mailbox *box,
const struct mailbox_update *update, bool directory);
Expand Down
2 changes: 2 additions & 0 deletions src/lib-storage/index/dbox-multi/mdbox-storage.c
Expand Up @@ -171,6 +171,8 @@ int mdbox_mailbox_open(struct mailbox *box)
{
struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)box;

if (dbox_mailbox_check_existence(box) < 0)
return -1;
if (dbox_mailbox_open(box) < 0)
return -1;

Expand Down
3 changes: 3 additions & 0 deletions src/lib-storage/index/dbox-single/sdbox-storage.c
Expand Up @@ -333,6 +333,9 @@ static int sdbox_mailbox_open(struct mailbox *box)
struct sdbox_index_header hdr;
bool need_resize;

if (dbox_mailbox_check_existence(box) < 0)
return -1;

if (sdbox_mailbox_alloc_index(mbox) < 0)
return -1;

Expand Down

0 comments on commit ea4d545

Please sign in to comment.