args.buf = input;
args.buflen = sizeof(input);
+ unlink(file_path);
+
switch_ivr_record_file(session, &fh, file_path, &args, profile->max_record_len);
if (switch_file_exists(file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
uint32_t timeout, attempts = 0, retries = 0;
int failed = 0;
msg_type_t play_msg_type = MSG_NONE;
- char *dir_path = NULL, *file_path = NULL;
+ char *dir_path = NULL, *file_path = NULL, *tmp_file_path = NULL;
int total_new_messages = 0;
int total_saved_messages = 0;
int total_new_urgent_messages = 0;
} else {
switch_event_t *params;
file_path = switch_mprintf("%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, num, profile->file_ext);
+ tmp_file_path = switch_mprintf("%s%sgreeting_%d_TMP.%s", dir_path, SWITCH_PATH_SEPARATOR, num, profile->file_ext);
+ unlink(tmp_file_path);
+
TRY_CODE(create_file(session, profile, VM_RECORD_GREETING_MACRO, file_path, &message_len, SWITCH_TRUE, NULL, NULL));
+ switch_file_rename(tmp_file_path, file_path, switch_core_session_get_pool(session));
+
sql =
switch_mprintf("update voicemail_prefs set greeting_path='%s' where username='%s' and domain='%s'", file_path, myid,
domain_name);
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(sql);
switch_safe_free(file_path);
+ switch_safe_free(tmp_file_path);
switch_event_create_subclass(¶ms, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Action", "record-greeting");
} else if (!strcmp(input, profile->record_name_key)) {
switch_event_t *params;
file_path = switch_mprintf("%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext);
+ tmp_file_path = switch_mprintf("%s%srecorded_name_TMP.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext);
+ unlink(tmp_file_path);
TRY_CODE(create_file(session, profile, VM_RECORD_NAME_MACRO, file_path, &message_len, SWITCH_FALSE, NULL, NULL));
+ switch_file_rename(tmp_file_path, file_path, switch_core_session_get_pool(session));
sql = switch_mprintf("update voicemail_prefs set name_path='%s' where username='%s' and domain='%s'", file_path, myid, domain_name);
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(file_path);
+ switch_safe_free(tmp_file_path);
switch_safe_free(sql);
switch_event_create_subclass(¶ms, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
end:
+ switch_safe_free(file_path);
+
+ if (tmp_file_path) {
+ unlink(tmp_file_path);
+ free(tmp_file_path);
+ tmp_file_path = NULL;
+ }
+
if (switch_channel_ready(channel)) {
if (failed) {
status = switch_ivr_phrase_macro(session, VM_ABORT_MACRO, NULL, NULL, NULL);