]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Maildir: Fixed to work with LAYOUT=fs and non-empty DIRNAME.
authorTimo Sirainen <tss@iki.fi>
Sat, 15 Nov 2008 16:48:52 +0000 (18:48 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 15 Nov 2008 16:48:52 +0000 (18:48 +0200)
--HG--
branch : HEAD

src/lib-storage/index/maildir/maildir-storage.c

index 84b859cd054ec466b2a304ece1166f2c17a8d159..d9d59629d3cc568101805daf844bc313ef08146b 100644 (file)
@@ -930,19 +930,33 @@ maildir_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx
                if (stat(cur_path, &st2) < 0 || !S_ISDIR(st2.st_mode))
                        *flags |= MAILBOX_NOSELECT;
 
-               /* now we can figure out based on the link count if we have
-                  child mailboxes or not. for a selectable mailbox we have
-                  3 more links (cur/, new/ and tmp/) than non-selectable. */
-               if ((*flags & MAILBOX_NOSELECT) == 0) {
-                       if (st.st_nlink > 5)
-                               *flags |= MAILBOX_CHILDREN;
-                       else
-                               *flags |= MAILBOX_NOCHILDREN;
+               if (*ctx->list->set.maildir_name == '\0') {
+                       /* now we can figure out based on the link count if we
+                          have child mailboxes or not. for a selectable
+                          mailbox we have 3 more links (cur/, new/ and tmp/)
+                          than non-selectable. */
+                       if ((*flags & MAILBOX_NOSELECT) == 0) {
+                               if (st.st_nlink > 5)
+                                       *flags |= MAILBOX_CHILDREN;
+                               else
+                                       *flags |= MAILBOX_NOCHILDREN;
+                       } else {
+                               if (st.st_nlink > 2)
+                                       *flags |= MAILBOX_CHILDREN;
+                               else
+                                       *flags |= MAILBOX_NOCHILDREN;
+                       }
                } else {
-                       if (st.st_nlink > 2)
+                       /* link count 3 may mean either a selectable mailbox
+                          or a non-selectable mailbox with 1 child. */
+                       if (st.st_nlink > 3)
                                *flags |= MAILBOX_CHILDREN;
-                       else
-                               *flags |= MAILBOX_NOCHILDREN;
+                       else if (st.st_nlink == 3) {
+                               if ((*flags & MAILBOX_NOSELECT) != 0)
+                                       *flags |= MAILBOX_CHILDREN;
+                               else
+                                       *flags |= MAILBOX_NOCHILDREN;
+                       }
                }
        }
        return 1;