dovecot-2.2: lib-storage: istream-mail updates mail->expunged if...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jul 4 11:15:58 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/c95577fbbe5a
changeset: 17599:c95577fbbe5a
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jul 04 14:14:21 2014 +0300
description:
lib-storage: istream-mail updates mail->expunged if it notices ENOENT from parent stream.

diffstat:

 src/lib-storage/index/index-mail.c   |  16 ++++++++++------
 src/lib-storage/index/index-mail.h   |   1 +
 src/lib-storage/index/istream-mail.c |   7 ++++++-
 3 files changed, 17 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r 0902eded882f -r c95577fbbe5a src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Fri Jul 04 14:01:53 2014 +0300
+++ b/src/lib-storage/index/index-mail.c	Fri Jul 04 14:14:21 2014 +0300
@@ -900,6 +900,13 @@
 	return -1;
 }
 
+void index_mail_refresh_expunged(struct mail *mail)
+{
+	mail_index_refresh(mail->box->index);
+	if (mail_index_is_expunged(mail->transaction->view, mail->seq))
+		mail_set_expunged(mail);
+}
+
 void index_mail_stream_log_failure_for(struct index_mail *mail,
 				       struct istream *input)
 {
@@ -907,16 +914,13 @@
 
 	i_assert(input->stream_errno != 0);
 
-	errno = input->stream_errno;
-	if (errno == ENOENT) {
+	if (input->stream_errno == ENOENT) {
 		/* was the mail just expunged? we could get here especially if
 		   external attachments are used and the attachment is deleted
 		   before we've opened the file. */
-		mail_index_refresh(_mail->box->index);
-		if (mail_index_is_expunged(_mail->transaction->view, _mail->seq)) {
-			mail_set_expunged(_mail);
+		index_mail_refresh_expunged(_mail);
+		if (_mail->expunged)
 			return;
-		}
 	}
 	mail_storage_set_critical(_mail->box->storage,
 		"read(%s) failed: %s (uid=%u, box=%s)",
diff -r 0902eded882f -r c95577fbbe5a src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h	Fri Jul 04 14:01:53 2014 +0300
+++ b/src/lib-storage/index/index-mail.h	Fri Jul 04 14:14:21 2014 +0300
@@ -234,6 +234,7 @@
 int index_mail_stream_check_failure(struct index_mail *mail);
 void index_mail_stream_log_failure_for(struct index_mail *mail,
 				       struct istream *input);
+void index_mail_refresh_expunged(struct mail *mail);
 struct index_mail *index_mail_get_index_mail(struct mail *mail);
 
 bool index_mail_get_cached_uoff_t(struct index_mail *mail,
diff -r 0902eded882f -r c95577fbbe5a src/lib-storage/index/istream-mail.c
--- a/src/lib-storage/index/istream-mail.c	Fri Jul 04 14:01:53 2014 +0300
+++ b/src/lib-storage/index/istream-mail.c	Fri Jul 04 14:14:21 2014 +0300
@@ -84,8 +84,13 @@
 			   doesn't have the body */
 			return -1;
 		}
-		if (stream->istream.stream_errno != 0)
+		if (stream->istream.stream_errno != 0) {
+			if (stream->istream.stream_errno == ENOENT) {
+				/* update mail's expunged-flag if needed */
+				index_mail_refresh_expunged(mstream->mail);
+			}
 			return -1;
+		}
 		if (i_stream_mail_try_get_cached_size(mstream) &&
 		    mstream->expected_size > stream->istream.v_offset + size) {
 			i_stream_mail_set_size_corrupted(mstream, size);


More information about the dovecot-cvs mailing list