From: Timo Sirainen Date: Wed, 12 Jul 2017 13:15:13 +0000 (+0300) Subject: lib-storage: Improve MAILBOX_LIST_PROP_AUTOCREATE_DIRS related comments X-Git-Tag: 2.3.0.rc1~1266 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17a951e7679ee11a926a030e359d70e7130f479d;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Improve MAILBOX_LIST_PROP_AUTOCREATE_DIRS related comments --- diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 6982587b06..1bdc228f27 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -2715,10 +2715,16 @@ int mailbox_create_missing_dir(struct mailbox *box, if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &mail_dir) < 0) return -1; - if (null_strcmp(dir, mail_dir) == 0) { - if ((box->list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) == 0) - return 0; - /* the directory might not have been created yet */ + if (null_strcmp(dir, mail_dir) != 0) { + /* Mailbox directory is different - create a missing dir */ + } else if ((box->list->props & MAILBOX_LIST_PROP_AUTOCREATE_DIRS) != 0) { + /* This layout (e.g. imapc) wants to autocreate missing mailbox + directories as well. */ + } else { + /* If the mailbox directory doesn't exist, the mailbox + shouldn't exist at all. So just assume that it's already + created and if there's a race condition just fail later. */ + return 0; } /* we call this function even when the directory exists, so first do a diff --git a/src/lib-storage/mailbox-list.h b/src/lib-storage/mailbox-list.h index 3cb09c53f3..bc9f098a89 100644 --- a/src/lib-storage/mailbox-list.h +++ b/src/lib-storage/mailbox-list.h @@ -23,7 +23,9 @@ enum mailbox_list_properties { MAILBOX_LIST_PROP_NO_NOSELECT = 0x04, /* mail root directory isn't required */ MAILBOX_LIST_PROP_NO_ROOT = 0x08, - /* Automatically create mailbox directories when needed */ + /* Automatically create mailbox directories when needed. Normally it's + assumed that if a mailbox directory doesn't exist, the mailbox + doesn't exist either. */ MAILBOX_LIST_PROP_AUTOCREATE_DIRS = 0x10 };