[asterisk-commits] seanbright: branch 1.4 r316707 - /branches/1.4/apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 4 11:08:56 CDT 2011


Author: seanbright
Date: Wed May  4 11:08:50 2011
New Revision: 316707

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=316707
Log:
If sox fails when processing a voicemail, don't delete the original file.

(closes issue #18111)
Reported by: sysreq
Patches:
      issue18111_trunk.patch uploaded by seanbright (license 71)
Tested by: seanbright

Modified:
    branches/1.4/apps/app_voicemail.c

Modified: branches/1.4/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/apps/app_voicemail.c?view=diff&rev=316707&r1=316706&r2=316707
==============================================================================
--- branches/1.4/apps/app_voicemail.c (original)
+++ branches/1.4/apps/app_voicemail.c Wed May  4 11:08:50 2011
@@ -3641,7 +3641,8 @@
 		char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
 		char tmpdir[256], newtmp[256];
 		int tmpfd = -1;
-	
+		int soxstatus = 0;
+
 		if (vmu->volgain < -.001 || vmu->volgain > .001) {
 			create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
 			snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
@@ -3650,7 +3651,6 @@
 			if (option_debug > 2)
 				ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
 			if (tmpfd > -1) {
-				int soxstatus;
 				snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
 				if ((soxstatus = ast_safe_system(tmpcmd)) == 0) {
 					attach = newtmp;
@@ -3673,7 +3673,9 @@
 		base_encode(fname, p);
 		fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound);
 		if (tmpfd > -1) {
-			unlink(fname);
+			if (soxstatus == 0) {
+				unlink(fname);
+			}
 			close(tmpfd);
 			unlink(newtmp);
 		}




More information about the asterisk-commits mailing list