From 1f98df36a66f5a8296a3393e7f1579243cd25228 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 25 Jul 2010 14:40:19 +0200 Subject: [PATCH] copiousoutput: Temporary file is deleted by /bin/rm -f added with ; at the of the command. I commented also the line with file_download->delete = 0 because it left temporary files. --- src/session/download.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/session/download.c b/src/session/download.c index dada4ddf..b919895c 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -363,21 +363,22 @@ exec_mailcap_command(void *data) if (exec_mailcap) { if (exec_mailcap->command) { - int length = strlen(exec_mailcap->command) - + sizeof("mailcap:"); - unsigned char *buf = malloc(length); + struct string string; - if (buf) { + if (init_string(&string)) { struct uri *ref = get_uri("mailcap:elmailcap", 0); struct uri *uri; struct session *ses = exec_mailcap->ses; - memcpy(buf, "mailcap:", 8); - memcpy(buf + 8, exec_mailcap->command, length - 9); - buf[length - 1] = '\0'; + add_to_string(&string, "mailcap:"); + add_to_string(&string, exec_mailcap->command); + if (exec_mailcap->file) { + add_to_string(&string, ";/bin/rm -f "); + add_to_string(&string, exec_mailcap->file); + } - uri = get_uri(buf, 0); - mem_free(buf); + uri = get_uri(string.source, 0); + done_string(&string); set_session_referrer(ses, ref); if (ref) done_uri(ref); @@ -457,14 +458,16 @@ download_data_store(struct download *download, struct file_download *file_downlo file_download->handle = -1; if (file_download->copiousoutput) { exec_later(file_download->ses, - file_download->external_handler, NULL); + file_download->external_handler, file_download->file); + /* Temporary file is deleted by the execute_mailcap */ + file_download->delete = 0; } else { exec_on_terminal(term, file_download->external_handler, file_download->file, file_download->block ? TERM_EXEC_FG : TERM_EXEC_BG); } - file_download->delete = 0; + /* file_download->delete = 0; */ abort_download_and_beep(file_download, term); return; }