dovecot-2.1: maildir: Whenever we're guessing a filename correct...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 9 13:14:35 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/b29d9d98f5c0
changeset: 13683:b29d9d98f5c0
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 09 13:24:49 2011 +0200
description:
maildir: Whenever we're guessing a filename correctly, remember it in uidlist.

diffstat:

 src/lib-storage/index/maildir/maildir-uidlist.c |  14 ++++++++++++++
 src/lib-storage/index/maildir/maildir-uidlist.h |   2 ++
 src/lib-storage/index/maildir/maildir-util.c    |  15 ++++++++++-----
 3 files changed, 26 insertions(+), 5 deletions(-)

diffs (67 lines):

diff -r 0a3eafad58c0 -r b29d9d98f5c0 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Wed Nov 09 12:55:37 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Wed Nov 09 13:24:49 2011 +0200
@@ -1868,6 +1868,20 @@
 	return TRUE;
 }
 
+void maildir_uidlist_update_fname(struct maildir_uidlist *uidlist,
+				  const char *filename)
+{
+	struct maildir_uidlist_rec *rec;
+
+	rec = hash_table_lookup(uidlist->files, filename);
+	if (rec == NULL)
+		return;
+
+	rec->flags &= ~MAILDIR_UIDLIST_REC_FLAG_NONSYNCED;
+	if (strcmp(rec->filename, filename) != 0)
+		rec->filename = p_strdup(uidlist->record_pool, filename);
+}
+
 const char *
 maildir_uidlist_get_full_filename(struct maildir_uidlist *uidlist,
 				  const char *filename)
diff -r 0a3eafad58c0 -r b29d9d98f5c0 src/lib-storage/index/maildir/maildir-uidlist.h
--- a/src/lib-storage/index/maildir/maildir-uidlist.h	Wed Nov 09 12:55:37 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.h	Wed Nov 09 13:24:49 2011 +0200
@@ -127,6 +127,8 @@
 				  struct maildir_uidlist_rec *rec,
 				  enum maildir_uidlist_rec_ext_key key,
 				  const char *value);
+void maildir_uidlist_update_fname(struct maildir_uidlist *uidlist,
+				  const char *filename);
 const char *
 maildir_uidlist_sync_get_full_filename(struct maildir_uidlist_sync_ctx *ctx,
 				       const char *filename);
diff -r 0a3eafad58c0 -r b29d9d98f5c0 src/lib-storage/index/maildir/maildir-util.c
--- a/src/lib-storage/index/maildir/maildir-util.c	Wed Nov 09 12:55:37 2011 +0200
+++ b/src/lib-storage/index/maildir/maildir-util.c	Wed Nov 09 13:24:49 2011 +0200
@@ -88,17 +88,22 @@
 					       &flags, &have_flags);
 	}
 
+	ret = 0;
 	if ((flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0) {
 		/* probably in new/ dir */
 		path = t_strconcat(mailbox_get_path(&mbox->box),
 				   "/new/", fname, NULL);
 		ret = callback(mbox, path, context);
-		if (ret != 0)
-			return ret;
 	}
-
-	path = t_strconcat(mailbox_get_path(&mbox->box), "/cur/", fname, NULL);
-	ret = callback(mbox, path, context);
+	if (ret == 0) {
+		path = t_strconcat(mailbox_get_path(&mbox->box), "/cur/",
+				   fname, NULL);
+		ret = callback(mbox, path, context);
+	}
+	if (ret > 0 && (flags & MAILDIR_UIDLIST_REC_FLAG_NONSYNCED) != 0) {
+		/* file was found. make sure we remember its latest name. */
+		maildir_uidlist_update_fname(mbox->uidlist, fname);
+	}
 	return ret;
 }
 


More information about the dovecot-cvs mailing list