summaryrefslogtreecommitdiffstats
path: root/copy.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-04-09 11:22:07 -0700
committerKevin McCarthy <kevin@8t8.us>2020-04-09 13:25:39 -0700
commit53a1b4ceeed7b14cdd5b8f4b4ae39143cbef2985 (patch)
tree37f5f1187a266e207b59de17ff2315542e8b03fd /copy.c
parent4fc97a2026f671a35e3d296bbfdeb3794d6313c7 (diff)
Convert "non-fatal" handler errors to return 1 instead of -1.
When displaying a message, display a mutt_error() to warn of incomplete rendering. Fix mutt_copy_message() to check for ferror and feof errors on partial decode too. Clean up _mutt_append_message() to not pass a partial-decode along as a success. Modify the crypt handlers to return 1 if any kind of state message is displayed. There is some fuzzyness about what a "fatal" error is, but for now just consider a handler error that notifies by state_attach_puts() as "non-fatal".
Diffstat (limited to 'copy.c')
-rw-r--r--copy.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/copy.c b/copy.c
index 9e6feffe..5e84b717 100644
--- a/copy.c
+++ b/copy.c
@@ -729,8 +729,14 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
return rc;
}
-/* should be made to return -1 on fatal errors, and 1 on non-fatal errors
- * like partial decode, where it is worth displaying as much as possible */
+/* Returns:
+ * 0 on success
+ * -1 on a fatal error
+ * 1 on a partial decode, or errors that are still deemed viewable
+ * by mutt_display_message() (such as decryption errors).
+ * Callers besides mutt_display_message should consider rc != 0 as
+ * failure.
+ */
int
mutt_copy_message (FILE *fpout, CONTEXT *src, HEADER *hdr, int flags,
int chflags)
@@ -740,8 +746,8 @@ mutt_copy_message (FILE *fpout, CONTEXT *src, HEADER *hdr, int flags,
if ((msg = mx_open_message (src, hdr->msgno)) == NULL)
return -1;
- if ((r = _mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags, chflags)) == 0
- && (ferror (fpout) || feof (fpout)))
+ r = _mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags, chflags);
+ if ((r >= 0) && (ferror (fpout) || feof (fpout)))
{
dprint (1, (debugfile, "_mutt_copy_message failed to detect EOF!\n"));
r = -1;
@@ -779,6 +785,9 @@ _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
chflags |= CH_FROM | CH_FORCE_FROM;
chflags |= (dest->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
r = _mutt_copy_message (msg->fp, fpin, hdr, body, flags, chflags);
+ /* Partial decode is still an error. */
+ if (r != 0)
+ r = -1;
if (mx_commit_message (msg, dest) != 0)
r = -1;