changeset 8400:ce4779b95fc8 HEAD

Maildir: Fixed to work with LAYOUT=fs and non-empty DIRNAME.
author Timo Sirainen <tss@iki.fi>
date Sat, 15 Nov 2008 18:48:52 +0200
parents 155700456194
children 83cad8a5bf15
files src/lib-storage/index/maildir/maildir-storage.c
diffstat 1 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-storage.c	Sat Nov 15 18:43:54 2008 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Sat Nov 15 18:48:52 2008 +0200
@@ -930,19 +930,33 @@
 		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)
+		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 {
+			/* 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 > 2)
-				*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;