]> granicus.if.org Git - neomutt/commitdiff
message.c: retry message parse if first attempt is zero-length
authorJoey Pabalinas <joeypabalinas@gmail.com>
Fri, 6 Apr 2018 12:40:27 +0000 (02:40 -1000)
committerRichard Russon <rich@flatcap.org>
Tue, 1 May 2018 13:54:09 +0000 (14:54 +0100)
On IMAP failure the message body can sometimes be truncated, which
leaves an empty message in the cache that must be manually deleted
to be properly re-fetched.

If the cached message body is zero-length, retry the message parse
once to be sure that the message body actually *is* empty.

imap/message.c

index 18f08348c88570978a0e8928d7ef706526be1b50..088895e2dbe2131dc79bd51d884337b39c9451fb 100644 (file)
@@ -989,6 +989,7 @@ int imap_fetch_message(struct Context *ctx, struct Message *msg, int msgno)
   unsigned int uid;
   int cacheno;
   struct ImapCache *cache = NULL;
+  bool retried = false;
   bool read;
   int rc;
 
@@ -1178,6 +1179,14 @@ parsemsg:
   rewind(msg->fp);
   HEADER_DATA(h)->parsed = true;
 
+  /* retry message parse if cached message is empty */
+  if (!retried && ((h->lines == 0) || (h->content->length == 0)))
+  {
+    imap_cache_del(idata, h);
+    retried = true;
+    goto parsemsg;
+  }
+
   return 0;
 
 bail: