]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
followme: delete the right recorded name file 29/2829/1
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>
Tue, 10 May 2016 13:17:29 +0000 (16:17 +0300)
committerJoshua Colp <jcolp@digium.com>
Fri, 13 May 2016 00:57:03 +0000 (19:57 -0500)
FollowMe with the option a records the name of the caller and plays it
to the callee. However it has failed to clean up that recorded file
as it tried to delete the file name without the '.sln' extension.

ASTERISK-26008 #close

Change-Id: I79d7b1be7d5cde57bf076d9389e2a8a4422776ec
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
apps/app_followme.c

index 9f39c329d64175a96030ce799c12b984f936c7f3..dfb0f0e62a42ac490896cd43726d9f10147c4840 100644 (file)
@@ -58,6 +58,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/dsp.h"
 #include "asterisk/app.h"
 
+#define REC_FORMAT "sln"
+
 /*** DOCUMENTATION
        <application name="FollowMe" language="en_US">
                <synopsis>
@@ -1419,7 +1421,7 @@ static int app_exec(struct ast_channel *chan, const char *data)
 
                        snprintf(targs->namerecloc, sizeof(targs->namerecloc), "%s/followme.%s",
                                ast_config_AST_SPOOL_DIR, ast_channel_uniqueid(chan));
-                       if (ast_play_and_record(chan, "vm-rec-name", targs->namerecloc, 5, "sln", &duration,
+                       if (ast_play_and_record(chan, "vm-rec-name", targs->namerecloc, 5, REC_FORMAT, &duration,
                                NULL, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE), 0, NULL) < 0) {
                                goto outrun;
                        }
@@ -1521,7 +1523,18 @@ outrun:
                ast_free(nm);
        }
        if (!ast_strlen_zero(targs->namerecloc)) {
-               unlink(targs->namerecloc);
+               int ret;
+               char fn[PATH_MAX];
+
+               snprintf(fn, sizeof(fn), "%s.%s", targs->namerecloc,
+                            REC_FORMAT);
+               ret = unlink(fn);
+               if (ret != 0) {
+                       ast_log(LOG_NOTICE, "Failed to delete recorded name file %s: %d (%s)\n",
+                                       fn, errno, strerror(errno));
+               } else {
+                       ast_debug(2, "deleted recorded prompt %s.\n", fn);
+               }
        }
        ast_free((char *) targs->predial_callee);
        ast_party_connected_line_free(&targs->connected_in);