diff --git a/src/switch_core_file.c b/src/switch_core_file.c index bc70feb140..b88dfe81cd 100644 --- a/src/switch_core_file.c +++ b/src/switch_core_file.c @@ -148,7 +148,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, switch_goto_status(status, end); } - if (!strstr(file_path, SWITCH_URL_SEPARATOR) && (status = switch_file_exists(file_path, fh->memory_pool)) != SWITCH_STATUS_SUCCESS) { + + if ((flags & SWITCH_FILE_FLAG_WRITE) && + !strstr(file_path, SWITCH_URL_SEPARATOR) && (status = switch_file_exists(file_path, fh->memory_pool)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File [%s] not created!\n", file_path); fh->file_interface->file_close(fh); UNPROTECT_INTERFACE(fh->file_interface);