From d7002351d74c88fd6e232656126578687fb2455e Mon Sep 17 00:00:00 2001 From: Marc Olivier Chouinard Date: Fri, 25 May 2012 07:18:55 -0400 Subject: [PATCH] mod_voicemail: Make sure vm_fsdb api create the user directory before trying to move file into it --- src/mod/applications/mod_voicemail/mod_voicemail.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 2ed70ce05d..0bbea275d5 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -4895,6 +4895,8 @@ SWITCH_STANDARD_API(vm_fsdb_pref_greeting_set_function) profile->name, SWITCH_PATH_SEPARATOR, domain, SWITCH_PATH_SEPARATOR, id); char *final_file_path = switch_core_sprintf(pool, "%s%sgreeting_%d.%s", dir_path, SWITCH_PATH_SEPARATOR, slot, profile->file_ext); + switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool); + if (file_path) { if (switch_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "-ERR Filename doesn't exist\n"); @@ -4989,6 +4991,8 @@ SWITCH_STANDARD_API(vm_fsdb_pref_recname_set_function) profile->name, SWITCH_PATH_SEPARATOR, domain, SWITCH_PATH_SEPARATOR, id); char *final_file_path = switch_core_sprintf(pool, "%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext); + switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, pool); + if (switch_file_exists(file_path, pool) != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "-ERR Filename doesn't exist\n"); profile_rwunlock(profile); @@ -4996,6 +5000,7 @@ SWITCH_STANDARD_API(vm_fsdb_pref_recname_set_function) } switch_file_rename(file_path, final_file_path, pool); + if (atoi(res) == 0) { sql = switch_mprintf("INSERT INTO voicemail_prefs (username, domain, name_path) VALUES('%q', '%q', '%q')", id, domain, final_file_path); } else {