dovecot-2.0: multi-dbox: Added save date to dbox index records s...

dovecot at dovecot.org dovecot at dovecot.org
Thu May 21 05:59:46 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/5ba40c164a2d
changeset: 9339:5ba40c164a2d
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 20 22:59:41 2009 -0400
description:
multi-dbox: Added save date to dbox index records so it won't be shared across mailboxes.

diffstat:

4 files changed, 29 insertions(+), 1 deletion(-)
src/lib-storage/index/dbox/dbox-mail.c            |   23 ++++++++++++++++++++-
src/lib-storage/index/dbox/dbox-save.c            |    2 +
src/lib-storage/index/dbox/dbox-storage-rebuild.c |    2 +
src/lib-storage/index/dbox/dbox-storage.h         |    3 ++

diffs (91 lines):

diff -r c47c961a9727 -r 5ba40c164a2d src/lib-storage/index/dbox/dbox-mail.c
--- a/src/lib-storage/index/dbox/dbox-mail.c	Wed May 20 22:52:55 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-mail.c	Wed May 20 22:59:41 2009 -0400
@@ -217,6 +217,24 @@ static int dbox_mail_get_received_date(s
 	return 0;
 }
 
+static bool multi_dbox_get_save_date(struct mail *mail, time_t *date_r)
+{
+	struct dbox_mailbox *mbox =
+		(struct dbox_mailbox *)mail->transaction->box;
+	const struct dbox_mail_index_record *dbox_rec;
+	const void *data;
+	bool expunged;
+
+	mail_index_lookup_ext(mbox->ibox.view, mail->seq,
+			      mbox->dbox_ext_id, &data, &expunged);
+	dbox_rec = data;
+	if (dbox_rec == NULL || dbox_rec->map_uid == 0)
+		return FALSE;
+
+	*date_r = dbox_rec->save_date;
+	return TRUE;
+}
+
 static int dbox_mail_get_save_date(struct mail *_mail, time_t *date_r)
 {
 	struct dbox_mail *mail = (struct dbox_mail *)_mail;
@@ -225,7 +243,10 @@ static int dbox_mail_get_save_date(struc
 	struct stat st;
 	const char *value;
 
-	if (index_mail_get_save_date(_mail, date_r) == 0)
+	if (multi_dbox_get_save_date(_mail, date_r))
+		return 0;
+
+ 	if (index_mail_get_save_date(_mail, date_r) == 0)
 		return 0;
 
 	if (dbox_mail_metadata_read(mail, &file) < 0)
diff -r c47c961a9727 -r 5ba40c164a2d src/lib-storage/index/dbox/dbox-save.c
--- a/src/lib-storage/index/dbox/dbox-save.c	Wed May 20 22:52:55 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-save.c	Wed May 20 22:59:41 2009 -0400
@@ -395,6 +395,7 @@ int dbox_transaction_save_commit_pre(str
 		dbox_add_missing_map_uidvalidity(ctx);
 
 		memset(&rec, 0, sizeof(rec));
+		rec.save_date = ioloop_time;
 		mails = array_get(&ctx->mails, &count);
 		for (i = 0; i < count; i++) {
 			if (mails[i].file->single_mbox != NULL)
@@ -487,6 +488,7 @@ int dbox_copy(struct mail_save_context *
 	src_mbox = (struct dbox_mailbox *)mail->box;
 
 	memset(&rec, 0, sizeof(rec));
+	rec.save_date = ioloop_time;
 	if (dbox_mail_lookup(src_mbox, src_mbox->ibox.view, mail->seq,
 			     &rec.map_uid) < 0)
 		return -1;
diff -r c47c961a9727 -r 5ba40c164a2d src/lib-storage/index/dbox/dbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox/dbox-storage-rebuild.c	Wed May 20 22:52:55 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-storage-rebuild.c	Wed May 20 22:59:41 2009 -0400
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "array.h"
+#include "ioloop.h"
 #include "istream.h"
 #include "hash.h"
 #include "hex-binary.h"
@@ -561,6 +562,7 @@ static int rebuild_restore_msg(struct db
 	/* add the new message */
 	memset(&dbox_rec, 0, sizeof(dbox_rec));
 	dbox_rec.map_uid = msg->map_uid;
+	dbox_rec.save_date = ioloop_time;
 	mail_index_append(ctx->prev_msg.trans, ctx->prev_msg.next_uid++, &seq);
 	mail_index_update_ext(ctx->prev_msg.trans, seq, mbox->dbox_ext_id,
 			      &dbox_rec, NULL);
diff -r c47c961a9727 -r 5ba40c164a2d src/lib-storage/index/dbox/dbox-storage.h
--- a/src/lib-storage/index/dbox/dbox-storage.h	Wed May 20 22:52:55 2009 -0400
+++ b/src/lib-storage/index/dbox/dbox-storage.h	Wed May 20 22:59:41 2009 -0400
@@ -58,6 +58,9 @@ struct dbox_storage {
 
 struct dbox_mail_index_record {
 	uint32_t map_uid;
+	/* UNIX timestamp of when the message was saved/copied to this
+	   mailbox */
+	uint32_t save_date;
 };
 
 struct dbox_mailbox {


More information about the dovecot-cvs mailing list