changeset 20730:a21e038e54c7

pop3-migration-plugin: Add to index after successful retry Also change return value to indicate that the hash has been assigned to header.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Fri, 09 Sep 2016 15:51:43 +0300
parents 6979003cba55
children 5b1f69b37089
files src/plugins/pop3-migration/pop3-migration-plugin.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/pop3-migration/pop3-migration-plugin.c	Mon Sep 12 09:47:26 2016 +0300
+++ b/src/plugins/pop3-migration/pop3-migration-plugin.c	Fri Sep 09 15:51:43 2016 +0300
@@ -238,6 +238,7 @@
 	const char *errstr;
 	enum mail_error error;
 	bool have_eoh;
+	int ret;
 
 	if (mail_get_hdr_stream(mail, &hdr_size, &input) < 0) {
 		errstr = mailbox_get_last_error(mail->box, &error);
@@ -282,10 +283,19 @@
 			mail->seq, errstr);
 		return error == MAIL_ERROR_EXPUNGED ? 0 : -1;
 	}
-	return pop3_migration_get_hdr_sha1(mail->seq, input,
-					   hdr_size.physical_size,
-					   sha1_r, &have_eoh);
-
+	ret = pop3_migration_get_hdr_sha1(mail->seq, input,
+					  hdr_size.physical_size,
+					  sha1_r, &have_eoh);
+	if (ret == 0) {
+		if (!have_eoh)
+			i_warning("pop3_migration: Truncated email with UID %u stored as truncated", mail->uid);
+		struct index_mail *imail = (struct index_mail *)mail;
+		index_mail_cache_add_idx(imail, get_cache_idx(mail),
+					 sha1_r, SHA1_RESULTLEN);
+		return 1;
+	} else {
+		return -1;
+	}
 }
 
 static bool