[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-sync.c, 1.18, 1.19 maildir-uidlist.c, 1.18, 1.19

cras at procontrol.fi cras at procontrol.fi
Sun May 23 01:23:31 EEST 2004


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

Modified Files:
	maildir-sync.c maildir-uidlist.c 
Log Message:
Recent flag fixes. Should work perfectly now with maildir.



Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- a/maildir-sync.c	22 May 2004 21:30:42 -0000	1.18
+++ b/maildir-sync.c	22 May 2004 22:23:29 -0000	1.19
@@ -442,6 +442,8 @@
 		ret = maildir_uidlist_sync_next_pre(ctx->uidlist_sync_ctx,
 						    dp->d_name);
 		if (ret == 0) {
+			/* new file and we couldn't lock uidlist, check this
+			   later in next sync. */
 			if (new_dir)
 				ctx->ibox->last_new_mtime = 0;
 			else
@@ -596,6 +598,13 @@
 	while (maildir_uidlist_iter_next(iter, &uid, &uflags, &filename)) {
 		maildir_filename_get_flags(filename, &flags, keywords);
 
+		if ((uflags & MAILDIR_UIDLIST_REC_FLAG_RECENT) != 0 &&
+		    (uflags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0 &&
+		    (uflags & MAILDIR_UIDLIST_REC_FLAG_MOVED) == 0) {
+			/* mail is recent for next session as well */
+			flags |= MAIL_RECENT;
+		}
+
 	__again:
 		seq++;
 		if ((uflags & MAILDIR_UIDLIST_REC_FLAG_NONSYNCED) != 0) {
@@ -673,14 +682,21 @@
 			continue;
 		}
 
-		maildir_filename_get_flags(filename, &flags, keywords);
-		if ((uint8_t)flags != (rec->flags & MAIL_FLAGS_MASK) ||
+		if (((uint8_t)flags & ~MAIL_RECENT) !=
+		    (rec->flags & (MAIL_FLAGS_MASK^MAIL_RECENT)) ||
 		    memcmp(keywords, rec->keywords,
 			   INDEX_KEYWORDS_BYTE_COUNT) != 0) {
-			/* FIXME: this is wrong if there's syncs later.
-			   it gets fixed in next sync however.. */
+			/* FIXME: this is wrong if there's pending changes in
+			   transaction log already. it gets fixed in next sync
+			   however.. */
 			mail_index_update_flags(trans, seq, MODIFY_REPLACE,
 						flags, keywords);
+		} else if ((flags & MAIL_RECENT) == 0 &&
+			   (rec->flags & MAIL_RECENT) != 0) {
+			/* just remove recent flag */
+			memset(keywords, 0, sizeof(keywords));
+			mail_index_update_flags(trans, seq, MODIFY_REMOVE,
+						MAIL_RECENT, keywords);
 		}
 	}
 	maildir_uidlist_iter_deinit(iter);

Index: maildir-uidlist.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-uidlist.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- a/maildir-uidlist.c	10 May 2004 18:39:51 -0000	1.18
+++ b/maildir-uidlist.c	22 May 2004 22:23:29 -0000	1.19
@@ -44,6 +44,7 @@
 	uint32_t first_recent_uid;
 
 	unsigned int initial_read:1;
+	unsigned int initial_sync:1;
 };
 
 struct maildir_uidlist_sync_ctx {
@@ -389,6 +390,18 @@
 	size_t size;
 	uint32_t count;
 
+	if (!uidlist->initial_sync) {
+		/* we haven't synced yet, trust index */
+		const struct mail_index_header *hdr;
+
+		if (mail_index_get_header(uidlist->ibox->view, &hdr) < 0)
+			return 0;
+		return hdr->recent_messages_count;
+	}
+
+	/* all recent messages were in new/ dir, so even if we did only
+	   a partial sync we should know all the recent messages. */
+
 	if (uidlist->first_recent_uid == 0)
 		return 0;
 
@@ -606,6 +619,10 @@
 		buffer_append(uidlist->record_buf, &rec, sizeof(rec));
 	}
 
+	if ((flags & MAILDIR_UIDLIST_REC_FLAG_RECENT) != 0 &&
+	    rec->uid != (uint32_t)-1)
+		maildir_uidlist_mark_recent(uidlist, rec->uid);
+
 	rec->flags = (rec->flags | flags) & ~MAILDIR_UIDLIST_REC_FLAG_NONSYNCED;
 	rec->filename = p_strdup(uidlist->record_pool, filename);
 	hash_insert(uidlist->files, rec->filename, rec);
@@ -777,6 +794,7 @@
 		}
 	}
 	ctx->finished = TRUE;
+	ctx->uidlist->initial_sync = TRUE;
 	return !ctx->locked;
 }
 



More information about the dovecot-cvs mailing list