Mercurial > dovecot > core-2.2
changeset 22291:5a81b1690625
sdbox: Don't create index directory when trying to open nonexistent mailboxes
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 27 Jun 2017 16:55:34 +0300 |
parents | f01b39a6d3b4 |
children | d192449acace |
files | src/lib-storage/index/dbox-common/dbox-storage.c src/lib-storage/index/dbox-common/dbox-storage.h src/lib-storage/index/dbox-multi/mdbox-storage.c src/lib-storage/index/dbox-single/sdbox-storage.c |
diffstat | 4 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-common/dbox-storage.c Fri Jun 30 13:56:54 2017 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.c Tue Jun 27 16:55:34 2017 +0300 @@ -190,7 +190,7 @@ 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); @@ -209,7 +209,11 @@ "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,
--- a/src/lib-storage/index/dbox-common/dbox-storage.h Fri Jun 30 13:56:54 2017 +0300 +++ b/src/lib-storage/index/dbox-common/dbox-storage.h Tue Jun 27 16:55:34 2017 +0300 @@ -70,6 +70,7 @@ 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);
--- a/src/lib-storage/index/dbox-multi/mdbox-storage.c Fri Jun 30 13:56:54 2017 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c Tue Jun 27 16:55:34 2017 +0300 @@ -171,6 +171,8 @@ { 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;
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c Fri Jun 30 13:56:54 2017 +0300 +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c Tue Jun 27 16:55:34 2017 +0300 @@ -333,6 +333,9 @@ 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;