[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-list.c, 1.26, 1.27

cras at dovecot.org cras at dovecot.org
Sat Sep 11 13:23:43 EEST 2004


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv6126/lib-storage/index/mbox

Modified Files:
	mbox-list.c 
Log Message:
Make sure we return always one correct INBOX list entry.



Index: mbox-list.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-list.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mbox-list.c	22 Jul 2004 21:20:01 -0000	1.26
+++ mbox-list.c	11 Sep 2004 10:23:40 -0000	1.27
@@ -34,7 +34,7 @@
 	struct imap_match_glob *glob;
 	struct subsfile_list_context *subsfile_ctx;
 
-	int failed;
+	int failed, inbox_found;
 
 	struct mailbox_list *(*next)(struct mbox_list_context *ctx);
 
@@ -259,6 +259,15 @@
 		return -1;
 	}
 
+	/* make sure we give only one correct INBOX */
+	if (strcasecmp(list_path, "INBOX") == 0) {
+		if (ctx->inbox_found ||
+		    strcmp(real_path, ctx->istorage->inbox_path) != 0)
+			return 0;
+
+		ctx->inbox_found = TRUE;
+	}
+
 	if (!noselect && S_ISDIR(st.st_mode)) {
 		/* subdirectory. scan inside it. */
 		path = t_strconcat(list_path, "/", NULL);
@@ -361,6 +370,29 @@
 		return ctx->next(ctx);
 }
 
+static struct mailbox_list *mbox_list_inbox(struct mbox_list_context *ctx)
+{
+	struct stat st;
+
+	ctx->list.flags = MAILBOX_NOINFERIORS;
+	ctx->list.name = "INBOX";
+
+	if (stat(ctx->istorage->inbox_path, &st) == 0)
+		ctx->list.flags |= STAT_GET_MARKED(st);
+	else if (errno == EACCES || errno == ELOOP)
+		ctx->list.flags = MAILBOX_NOSELECT;
+	else if (ENOTFOUND(errno))
+		ctx->list.flags |= MAILBOX_UNMARKED;
+	else {
+		mail_storage_set_critical(ctx->mailbox_ctx.storage,
+			"stat(%s) failed: %m", ctx->istorage->inbox_path);
+		ctx->failed = TRUE;
+		return NULL;
+	}
+
+	return &ctx->list;
+}
+
 static struct mailbox_list *mbox_list_next(struct mbox_list_context *ctx)
 {
 	struct list_dir_context *dir;
@@ -389,6 +421,12 @@
 		list_dir_context_free(dir);
 	}
 
+	if (!ctx->inbox_found && imap_match(ctx->glob, "INBOX")  > 0) {
+		/* show inbox */
+		ctx->inbox_found = TRUE;
+		return mbox_list_inbox(ctx);
+	}
+
 	/* finished */
 	return NULL;
 }



More information about the dovecot-cvs mailing list