summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2007-06-21 19:54:40 +0000
committerMark Michelson <mmichelson@digium.com>2007-06-21 19:54:40 +0000
commit5bad80449e364a7ccc00c9e67cb7bc8e9f80d888 (patch)
tree53f18e7ccefa9484a4d8463d1bc386467b3ad94b /apps
parent8cbc226156e1dc4f02e8743eb76b028a53959178 (diff)
Merged revisions 70808 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r70808 | mmichelson | 2007-06-21 14:49:44 -0500 (Thu, 21 Jun 2007) | 4 lines When volgain is used don't leave a temporary file behind. (Closes Issue 8514, Reported and patched by ulogic, code reviewed by Jason Parker) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@70809 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_voicemail.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 42ef554a4..167f10849 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -2095,17 +2095,19 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
/* Eww. We want formats to tell us their own MIME type */
char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
char tmpdir[256], newtmp[256];
- int tmpfd;
+ int tmpfd = -1;
- create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
- snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
- tmpfd = mkstemp(newtmp);
- ast_debug(3, "newtmp: %s\n", newtmp);
if (vmu->volgain < -.001 || vmu->volgain > .001) {
- snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
- ast_safe_system(tmpcmd);
- attach = newtmp;
- ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+ create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
+ snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
+ tmpfd = mkstemp(newtmp);
+ ast_debug(3, "newtmp: %s\n", newtmp);
+ if (tmpfd > -1) {
+ snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
+ ast_safe_system(tmpcmd);
+ attach = newtmp;
+ ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+ }
}
fprintf(p, "--%s" ENDL, bound);
fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
@@ -2115,9 +2117,11 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
snprintf(fname, sizeof(fname), "%s.%s", attach, format);
base_encode(fname, p);
fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound);
- if (tmpfd > -1)
+ if (tmpfd > -1) {
+ unlink(fname);
close(tmpfd);
- unlink(newtmp);
+ unlink(newtmp);
+ }
}
#undef ENDL
}