dovecot-2.1: imapc: Fixed checking if mail is expunged.

dovecot at dovecot.org dovecot at dovecot.org
Sun Sep 4 18:29:50 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/5e3d217ceedf
changeset: 13389:5e3d217ceedf
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Sep 04 18:29:38 2011 +0300
description:
imapc: Fixed checking if mail is expunged.

diffstat:

 src/lib-storage/index/imapc/imapc-mail.c |  50 +++++++++++++++++--------------
 1 files changed, 28 insertions(+), 22 deletions(-)

diffs (81 lines):

diff -r 581597411f6b -r 5e3d217ceedf src/lib-storage/index/imapc/imapc-mail.c
--- a/src/lib-storage/index/imapc/imapc-mail.c	Sun Sep 04 18:29:21 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mail.c	Sun Sep 04 18:29:38 2011 +0300
@@ -34,6 +34,23 @@
 	index_mail_free(_mail);
 }
 
+static bool imapc_mail_is_expunged(struct mail *_mail)
+{
+	struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box;
+	struct imapc_msgmap *msgmap;
+	uint32_t lseq, rseq;
+
+	if (mbox->sync_view != NULL) {
+		/* check if another session has already expunged it */
+		if (!mail_index_lookup_seq(mbox->sync_view, _mail->uid, &lseq))
+			return TRUE;
+	}
+
+	/* check if we've received EXPUNGE for it */
+	msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box);
+	return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq);
+}
+
 static int imapc_mail_get_received_date(struct mail *_mail, time_t *date_r)
 {
 	struct index_mail *mail = (struct index_mail *)_mail;
@@ -46,8 +63,14 @@
 		if (imapc_mail_fetch(_mail, MAIL_FETCH_RECEIVED_DATE) < 0)
 			return -1;
 		if (data->received_date == (time_t)-1) {
-			mail_storage_set_critical(_mail->box->storage,
-				"imapc: Remote server didn't send INTERNALDATE");
+			if (_mail->expunged || imapc_mail_is_expunged(_mail))
+				mail_set_expunged(_mail);
+			else {
+				mail_storage_set_critical(_mail->box->storage,
+					"imapc: Remote server didn't send "
+					"INTERNALDATE for UID %u", _mail->uid);
+				sleep(3600);
+			}
 			return -1;
 		}
 	}
@@ -98,25 +121,6 @@
 	return 0;
 }
 
-static bool imapc_mail_is_expunged(struct mail *_mail)
-{
-	struct imapc_mailbox *mbox = (struct imapc_mailbox *)_mail->box;
-	struct imapc_msgmap *msgmap;
-	uint32_t lseq, rseq;
-
-	/* first we'll need to convert the mail's sequence to sync_view's
-	   sequence. if there's no sync_view, then no mails have been
-	   expunged. */
-	if (mbox->sync_view == NULL)
-		return FALSE;
-
-	if (!mail_index_lookup_seq(mbox->sync_view, _mail->uid, &lseq))
-		return TRUE;
-
-	msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box);
-	return !imapc_msgmap_uid_to_rseq(msgmap, _mail->uid, &rseq);
-}
-
 static int
 imapc_mail_get_stream(struct mail *_mail, struct message_size *hdr_size,
 		      struct message_size *body_size, struct istream **stream_r)
@@ -141,7 +145,9 @@
 				mail_set_expunged(_mail);
 			else {
 				mail_storage_set_critical(_mail->box->storage,
-					"imapc: Remote server didn't send BODY[]");
+					"imapc: Remote server didn't send "
+					"BODY[] for UID %u", _mail->uid);
+				sleep(3600);
 			}
 			return -1;
 		}


More information about the dovecot-cvs mailing list