From: Anthony Minessale Date: Thu, 12 Jan 2012 23:06:13 +0000 (-0600) Subject: fix issue with caching invalid files on bad fetches X-Git-Tag: v1.2-rc1~19^2~1^2~60^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49f38848a994b025b872a66b20535c3e35c49b88;p=thirdparty%2Ffreeswitch.git fix issue with caching invalid files on bad fetches --- diff --git a/src/mod/applications/mod_httapi/mod_httapi.c b/src/mod/applications/mod_httapi/mod_httapi.c index 229d3a03b0..d101c7d3bb 100644 --- a/src/mod/applications/mod_httapi/mod_httapi.c +++ b/src/mod/applications/mod_httapi/mod_httapi.c @@ -2433,6 +2433,11 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char } } + if (switch_file_exists(context->cache_file, context->pool) != SWITCH_STATUS_SUCCESS && unreachable) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File at url [%s] is unreachable!\n", url); + goto end; + } + if (!unreachable && !zstr(context->metadata)) { metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s", url, @@ -2562,6 +2567,11 @@ static switch_status_t http_file_file_open(switch_file_handle_t *handle, const c handle->channels, handle->samplerate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL)) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid cache file %s opening url %s Discarding file.\n", context->cache_file, path); + unlink(context->cache_file); + unlink(context->meta_file); + unlink(context->lock_file); + return status; } }