From: Marco van Wieringen Date: Thu, 8 Nov 2012 09:10:40 +0000 (+0100) Subject: Fix bug #1948 MailOnSuccess get executed on error. X-Git-Tag: Release-7.0.0~82 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9eb0c4b1726d412818e85a9ed7aa6ede6638192d;p=bacula%2Fbacula Fix bug #1948 MailOnSuccess get executed on error. MailOnSuccess running when Job is cancelled or ends with errors. --- 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);