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.
unsigned int uid;
int cacheno;
struct ImapCache *cache = NULL;
+ bool retried = false;
bool read;
int rc;
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: