fix issue where file isn't in database and move zstr check into switch_file_exists

This commit is contained in:
Brian West 2010-05-06 16:25:23 -05:00
parent ef18989d56
commit f254787c02
2 changed files with 12 additions and 8 deletions

View File

@ -1445,7 +1445,9 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
*cc.buf = '\0';
memset(&fh, 0, sizeof(fh));
cc.fh = &fh;
TRY_CODE(switch_ivr_play_file(session, &fh, cbt->file_path, &args));
if (switch_file_exists(cbt->file_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
TRY_CODE(switch_ivr_play_file(session, &fh, cbt->file_path, &args));
}
}
if (!*cc.buf && (profile->play_date_announcement == VM_DATE_LAST)) {
@ -3005,11 +3007,11 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL);
if (!zstr(greet_path)) {
if (switch_file_exists(greet_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
memset(buf, 0, sizeof(buf));
TRY_CODE(switch_ivr_play_file(session, NULL, greet_path, &args));
} else {
if (!zstr(cbt.name_path)) {
if (switch_file_exists(cbt.name_path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
memset(buf, 0, sizeof(buf));
TRY_CODE(switch_ivr_play_file(session, NULL, cbt.name_path, &args));
}

View File

@ -507,15 +507,17 @@ SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_
switch_status_t status = SWITCH_STATUS_FALSE;
apr_finfo_t info = { 0 };
if (zstr(filename)) {
return status;
}
if (!pool) {
switch_core_new_memory_pool(&our_pool);
}
if (filename) {
apr_stat(&info, filename, wanted, pool ? pool : our_pool);
if (info.filetype != APR_NOFILE) {
status = SWITCH_STATUS_SUCCESS;
}
apr_stat(&info, filename, wanted, pool ? pool : our_pool);
if (info.filetype != APR_NOFILE) {
status = SWITCH_STATUS_SUCCESS;
}
if (our_pool) {