From 8444b4270da7e23bfa17fb29fa86da946ad9cff6 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Mon, 4 Jul 2022 11:28:16 -0600 Subject: * Improvements to error detection for the eXternal command. --- alpine/mailpart.c | 32 +++++++++++++++++++++----------- pith/pine.hlp | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/alpine/mailpart.c b/alpine/mailpart.c index 0e86d5a1..1c69391f 100644 --- a/alpine/mailpart.c +++ b/alpine/mailpart.c @@ -1449,7 +1449,7 @@ write_attachment(int qline, long int msgno, ATTACH_S *a, char *method) int write_attachment_to_file(MAILSTREAM *stream, long int msgno, ATTACH_S *a, int flags, char *file) { - char *l_string, sbuf[256], *err; + char *l_string, sbuf[256], *err, *err2 = NULL; int is_text, we_cancel = 0, dt_flags = 0, so_flags; long len, orig_size; gf_io_t pc; @@ -1491,9 +1491,9 @@ write_attachment_to_file(MAILSTREAM *stream, long int msgno, ATTACH_S *a, int fl cancel_busy_cue(0); if(so_give(&store)) /* close file */ - err = error_description(errno); + err2 = error_description(errno); - if(err){ + if(err || err2){ if(!(flags & (GER_APPEND | GER_OVER))) our_unlink(file); else @@ -1502,7 +1502,7 @@ write_attachment_to_file(MAILSTREAM *stream, long int msgno, ATTACH_S *a, int fl q_status_message2(SM_ORDER | SM_DING, 3, 5, /* TRANSLATORS: : Error writing attachment to */ _("%s: Error writing attachment to \"%s\""), - err, file); + err ? err : err2, file); return -1; } else{ @@ -2003,7 +2003,7 @@ display_html_external_attachment(long int msgno, ATTACH_S *a, int flags) STORE_S *store; gf_io_t pc; char *err; - int we_cancel = 0, saved, errs; + int we_cancel = 0, errs; char *tool; ATTACH_S *att; unsigned long rawno; @@ -2095,15 +2095,14 @@ display_html_external_attachment(long int msgno, ATTACH_S *a, int flags) so_give(&store); /*----- Download all needed inline attachments ------*/ - saved = errs = 0; + errs = 0; rawno = mn_m2raw(ps_global->msgmap, msgno); for (att = ps_global->atmts; rawno > 0 && att->description != NULL; att++){ if(att->cid_tmpfile){ if(write_attachment_to_file(ps_global->mail_stream, rawno, - att, GER_NONE, att->cid_tmpfile) == 1) - saved++; - else - errs++; + att, GER_NONE, att->cid_tmpfile) != 1 + || name_file_size(att->cid_tmpfile) == 0L) + errs++; fs_give((void **) &att->cid_tmpfile); } if(att->tmpdir) @@ -2112,7 +2111,7 @@ display_html_external_attachment(long int msgno, ATTACH_S *a, int flags) if(err){ q_status_message2(SM_ORDER | SM_DING, 3, 5, - "%s: Error saving image to temp file %s", + "%s: Error saving message to temp file %s", err, filename); if(filename){ our_unlink(filename); @@ -2121,6 +2120,17 @@ display_html_external_attachment(long int msgno, ATTACH_S *a, int flags) return(1); } + switch(errs){ + case 0 : break; + case 1 : q_status_message(SM_ORDER | SM_DING, 3, 5, + "Failed to download one image. Continuing..."); + break; + default: q_status_message1(SM_ORDER | SM_DING, 3, 5, + "Failed to download %s images. Continuing...", + int2string(errs)); + break; + } + tool = get_url_external_handler("http://", 1); if(tool == NULL) tool = get_url_external_handler("http://", 0); if(tool == NULL) tool = get_url_external_handler("https://", 1); diff --git a/pith/pine.hlp b/pith/pine.hlp index ae908ffe..e89383c6 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -147,7 +147,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 656 2022-06-19 09:27:58 +Alpine Commit 657 2022-07-04 11:28:11 ============= h_news ================= -- cgit v1.2.3-70-g09d2