]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
sdbox: Don't create index directory when trying to open nonexistent mailboxes
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 27 Jun 2017 13:55:34 +0000 (16:55 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 3 Jul 2017 12:24:28 +0000 (15:24 +0300)
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

index 9e24659dbbccd47c334428d83152dc6465c524b5..55d4b3db63562f907f5922f8af19ba439fa36734 100644 (file)
@@ -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);
 
@@ -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,
index 08daa91479bf1df0cd979486ac046063d7ab10be..f6117a27b17fb95297983c5c11d18ef2e41e379a 100644 (file)
@@ -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);
index 19ab9665ae4c0125b72814c42c919fc445aa5645..74718ef2cac83d68d35abbae54ed55f37d075092 100644 (file)
@@ -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;
 
index 1a628d5eda61340e68859a3810b88f19ca25c285..049c9345daf897e80f63fcf84ac1a00a34b7717b 100644 (file)
@@ -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;