dovecot-2.2: imap: Fixed partial FETCHes.

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 3 02:29:27 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/99843f74422a
changeset: 15177:99843f74422a
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 03 02:29:02 2012 +0300
description:
imap: Fixed partial FETCHes.

diffstat:

 src/lib-imap-storage/imap-msgpart.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (52 lines):

diff -r 4a074827375d -r 99843f74422a src/lib-imap-storage/imap-msgpart.c
--- a/src/lib-imap-storage/imap-msgpart.c	Wed Oct 03 02:28:44 2012 +0300
+++ b/src/lib-imap-storage/imap-msgpart.c	Wed Oct 03 02:29:02 2012 +0300
@@ -413,10 +413,9 @@
 {
 	struct mail_msgpart_partial_cache *cache = &mail->box->partial_cache;
 	struct istream *crlf_input;
-	const unsigned char *data;
-	size_t size;
 	uoff_t physical_start = input->v_offset;
 	uoff_t virtual_skip = msgpart->partial_offset;
+	bool cr_skipped;
 
 	i_assert(msgpart->headers == NULL); /* HEADER.FIELDS returns CRLFs */
 
@@ -433,27 +432,28 @@
 		   message parts. */
 		skip_using_parts(mail, input, physical_start, &virtual_skip);
 	}
-	crlf_input = i_stream_create_crlf(input);
-	i_stream_unref(&input);
-	input = crlf_input;
-	i_stream_skip(input, virtual_skip);
+	if (message_skip_virtual(input, virtual_skip, &cr_skipped) < 0)
+		return i_stream_create_error(errno);
 
 	if ((msgpart->partial_offset != 0 ||
-	     msgpart->partial_size != (uoff_t)-1) &&
-	    i_stream_read_data(input, &data, &size, 0) > 0) {
+	     msgpart->partial_size != (uoff_t)-1) && !input->eof) {
 		/* update cache */
 		cache->uid = mail->uid;
 		cache->physical_start = physical_start;
 		cache->physical_pos = input->v_offset;
 		cache->virtual_pos = msgpart->partial_offset;
-		if (data[0] == '\n') {
+		if (cr_skipped) {
 			/* the physical_pos points to virtual CRLF, but
 			   virtual_pos already skipped CR. that can't work,
 			   so seek back the virtual CR */
 			cache->virtual_pos--;
 		}
 	}
-	return input;
+	crlf_input = i_stream_create_crlf(input);
+	if (cr_skipped)
+		i_stream_skip(crlf_input, 1);
+	i_stream_unref(&input);
+	return crlf_input;
 }
 
 static void


More information about the dovecot-cvs mailing list