]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix issue with caching invalid files on bad fetches
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 12 Jan 2012 23:06:13 +0000 (17:06 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 12 Jan 2012 23:06:30 +0000 (17:06 -0600)
src/mod/applications/mod_httapi/mod_httapi.c

index 229d3a03b0396a44fcad73c707dd35d0556e04b4..d101c7d3bb9f5a9d200f8e271ffdb2d32d88ea90 100644 (file)
@@ -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;
                }
        }