From bbf45dabfab6ecd7438e591693aa42d71be75c66 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Thu, 8 Nov 2012 10:10:40 +0100 Subject: [PATCH] Fix bug #1948 MailOnSuccess get executed on error. MailOnSuccess running when Job is cancelled or ends with errors. --- bacula/src/lib/message.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index fb3c45eaff..c510563488 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -544,20 +544,39 @@ void close_msg(JCR *jcr) if (!d->fd) { break; } - if ( - (d->dest_code == MD_MAIL_ON_ERROR && jcr && - (jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings)) - || - (d->dest_code == MD_MAIL_ON_SUCCESS && jcr && - jcr->JobStatus == JS_ErrorTerminated) - ) { - goto rem_temp_file; + + switch (d->dest_code) { + case MD_MAIL_ON_ERROR: + if (jcr) { + switch (jcr->JobStatus) { + case JS_Terminated: + case JS_Warnings: + goto rem_temp_file; + default: + break; + } + } + break; + case MD_MAIL_ON_SUCCESS: + if (jcr) { + switch (jcr->JobStatus) { + case JS_Terminated: + case JS_Warnings: + break; + default: + goto rem_temp_file; + } + } + break; + default: + break; } if (!(bpipe=open_mail_pipe(jcr, cmd, d))) { Pmsg0(000, _("open mail pipe failed.\n")); goto rem_temp_file; } + Dmsg0(850, "Opened mail pipe\n"); len = d->max_len+10; line = get_memory(len); -- 2.39.5