[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-list.c, 1.29, 1.30

cras at procontrol.fi cras at procontrol.fi
Sun May 30 01:21:41 EEST 2004


Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv32116/src/lib-storage/index/maildir

Modified Files:
	maildir-list.c 
Log Message:
Added maildir_stat_dirs option.



Index: maildir-list.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-list.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- a/maildir-list.c	24 May 2004 22:13:55 -0000	1.29
+++ b/maildir-list.c	29 May 2004 22:21:39 -0000	1.30
@@ -10,6 +10,7 @@
 #include "maildir-storage.h"
 #include "mailbox-tree.h"
 
+#include <stdlib.h>
 #include <dirent.h>
 #include <sys/stat.h>
 
@@ -53,11 +54,12 @@
 {
 	DIR *dirp;
 	struct dirent *d;
+	struct stat st;
 	const char *path, *p, *mailbox_c;
 	string_t *mailbox;
 	enum imap_match_result match;
 	struct mailbox_node *node;
-	int created;
+	int stat_dirs, created, hide;
 
 	dirp = opendir(ctx->dir);
 	if (dirp == NULL) {
@@ -75,6 +77,8 @@
 		node->flags &= ~(MAILBOX_PLACEHOLDER | MAILBOX_NONEXISTENT);
 	}
 
+	stat_dirs = getenv("MAILDIR_STAT_DIRS") != NULL;
+
 	mailbox = t_str_new(PATH_MAX);
 	while ((d = readdir(dirp)) != NULL) {
 		const char *fname = d->d_name;
@@ -87,10 +91,22 @@
 		    (fname[1] == '\0' || (fname[1] == '.' && fname[2] == '\0')))
 			continue;
 
-		/* FIXME: kludges. these files must be renamed later */
-		if (strcmp(fname, ".customflags") == 0 ||
-		    strcmp(fname, ".subscriptions") == 0)
+#ifdef HAVE_DIRENT_D_TYPE
+		/* check the type always since there's no extra cost */
+		if (d->d_type == DT_DIR)
+			;
+		else if (d->d_type != DT_UNKNOWN)
 			continue;
+		else
+#endif
+		if (stat_dirs) {
+			t_push();
+			path = t_strdup_printf("%s/%s", ctx->dir, fname);
+			hide = stat(path, &st) < 0 || !S_ISDIR(st.st_mode);
+			t_pop();
+			if (hide)
+				continue;
+		}
 
 		if (fname[1] == MAILDIR_FS_SEP) {
 			/* this mailbox is in the middle of being deleted,
@@ -99,8 +115,6 @@
 			   delete it ourself if it's been there longer than
 			   one hour. don't touch it if it's outside our
 			   mail root dir. */
-			struct stat st;
-
 			t_push();
 			path = t_strdup_printf("%s/%s", ctx->dir, fname);
 			if (stat(path, &st) == 0 &&



More information about the dovecot-cvs mailing list