]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Improve MAILBOX_LIST_PROP_AUTOCREATE_DIRS related comments
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 13:15:13 +0000 (16:15 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 21:45:38 +0000 (00:45 +0300)
src/lib-storage/mail-storage.c
src/lib-storage/mailbox-list.h

index fa12e77fa9d9af0aeb30764d06d1ffe1b208fb27..37a2851c59a7bb7092fff8fe9cec88f8cce091e0 100644 (file)
@@ -2708,10 +2708,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
index 3cb09c53f375b83c212d3ca561b75d4e4f812e2d..bc9f098a8963856c46cf20c5c61bbf87589b92c4 100644 (file)
@@ -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
 };