diff src/lib-index/mail-index-transaction-view.c @ 4333:8bfdd3928097 HEAD

mail_index_lookup() and mail_index_lookup_full() returns now 0 if the mail has been expunged within the transaction.
author Timo Sirainen <timo.sirainen@movial.fi>
date Mon, 12 Jun 2006 15:27:29 +0300
parents 928229f8b3e6
children 1a35d53c18fc
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-view.c	Mon Jun 12 11:36:51 2006 +0300
+++ b/src/lib-index/mail-index-transaction-view.c	Mon Jun 12 15:27:29 2006 +0300
@@ -1,8 +1,9 @@
-/* Copyright (C) 2004 Timo Sirainen */
+/* Copyright (C) 2004-2006 Timo Sirainen */
 
 #include "lib.h"
 #include "array.h"
 #include "buffer.h"
+#include "seq-range-array.h"
 #include "mail-index-private.h"
 #include "mail-index-view-private.h"
 #include "mail-index-transaction-private.h"
@@ -48,6 +49,7 @@
 {
 	struct mail_index_view_transaction *tview =
                 (struct mail_index_view_transaction *)view;
+	int ret;
 
 	if (seq >= tview->t->first_new_seq) {
 		/* FIXME: is this right to return index map..?
@@ -55,9 +57,16 @@
 		*map_r = view->index->map;
 		*rec_r = mail_index_transaction_lookup(tview->t, seq);
 		return 1;
-	} else {
-		return tview->parent->lookup_full(view, seq, map_r, rec_r);
 	}
+
+	ret = tview->parent->lookup_full(view, seq, map_r, rec_r);
+	if (ret <= 0)
+		return ret;
+
+	/* if we're expunged within this transaction, return 0 */
+	return array_is_created(&tview->t->expunges) &&
+		seq_range_exists(&tview->t->expunges, seq) ? 0 : 1;
+
 }
 
 static int _tview_lookup_uid(struct mail_index_view *view, uint32_t seq,