提交 a684e751 authored 作者: Anthony Minessale's avatar Anthony Minessale

fix cache file messup

上级 e917202d
...@@ -2289,7 +2289,7 @@ SWITCH_STANDARD_APP(httapi_function) ...@@ -2289,7 +2289,7 @@ SWITCH_STANDARD_APP(httapi_function)
static char *load_cache_data(http_file_context_t *context, const char *url) static char *load_cache_data(http_file_context_t *context, const char *url)
{ {
char *ext = NULL; char *ext = NULL, *dext = NULL, *p;
char digest[SWITCH_MD5_DIGEST_STRING_SIZE] = { 0 }; char digest[SWITCH_MD5_DIGEST_STRING_SIZE] = { 0 };
char meta_buffer[1024] = ""; char meta_buffer[1024] = "";
int fd; int fd;
...@@ -2308,6 +2308,14 @@ static char *load_cache_data(http_file_context_t *context, const char *url) ...@@ -2308,6 +2308,14 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
ext = "wav"; ext = "wav";
} }
} }
if (ext && (p = strchr(ext, '?'))) {
dext = strdup(ext);
if ((p = strchr(dext, '?'))) {
*p = '\0';
ext = dext;
} else free(dext);
}
context->cache_file_base = switch_core_sprintf(context->pool, "%s%s%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest); context->cache_file_base = switch_core_sprintf(context->pool, "%s%s%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest);
context->cache_file = switch_core_sprintf(context->pool, "%s%s%s.%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest, ext); context->cache_file = switch_core_sprintf(context->pool, "%s%s%s.%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest, ext);
...@@ -2329,6 +2337,8 @@ static char *load_cache_data(http_file_context_t *context, const char *url) ...@@ -2329,6 +2337,8 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
close(fd); close(fd);
} }
switch_safe_free(dext);
return context->cache_file; return context->cache_file;
} }
...@@ -2600,6 +2610,12 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char ...@@ -2600,6 +2610,12 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
if (newext) { if (newext) {
char *p;
if ((p = strrchr(context->cache_file, '.'))) {
*p = '\0';
}
context->cache_file = switch_core_sprintf(context->pool, "%s.%s", context->cache_file, newext); context->cache_file = switch_core_sprintf(context->pool, "%s.%s", context->cache_file, newext);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论