From: Brendan Cully Date: Tue, 2 Aug 2005 02:01:46 +0000 (+0000) Subject: Check that the entire message downloaded successfully on fetch, and don't X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=becf6619e4565090d058d88135407fbebf86c87d;p=neomutt Check that the entire message downloaded successfully on fetch, and don't treat a disappearing cache file as fatal. (closes #1483) --- diff --git a/imap/message.c b/imap/message.c index f0c856cd6..d7ce21d7d 100644 --- a/imap/message.c +++ b/imap/message.c @@ -343,19 +343,12 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) if (cache->path) { - if (cache->uid == HEADER_DATA(h)->uid) - { - /* yes, so just return a pointer to the message */ - if (!(msg->fp = fopen (cache->path, "r"))) - { - mutt_perror (cache->path); - return (-1); - } + /* don't treat cache errors as fatal, just fall back. */ + if (cache->uid == HEADER_DATA(h)->uid && + (msg->fp = fopen (cache->path, "r"))) return 0; - } else { - /* clear the previous entry */ unlink (cache->path); FREE (&cache->path); } @@ -442,6 +435,13 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) /* see comment before command start. */ h->active = 1; + fflush (msg->fp); + if (ferror (msg->fp)) + { + mutt_perror (cache->path); + goto bail; + } + if (rc != IMAP_CMD_OK) goto bail;