diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index ec9ded79006f3399b019476f15f30126e0384a4f..724ba5d165cd1ec20be612844cc5a76ff9da48f6 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -2565,9 +2565,14 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ ast_log(LOG_WARNING, "Error opening text file for output\n"); res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration, dir, options->record_gain); if (res == '0') { - if (txt) { + if (txt && EXISTS(dir,msgnum,fn,chan->language)) { fclose(txt); rename(tmptxtfile, txtfile); + } else if (!EXISTS(dir,msgnum,fn,chan->language)) { + if (option_debug) + ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n"); + fclose(txt); + unlink(tmptxtfile); } goto transfer; }