author | Lars Hjemli <hjemli@gmail.com> | 2007-06-18 19:17:24 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-18 19:17:24 (UTC) |
commit | 7d6ee4ee8a2c79802a78bc09c0e1e96a7a82de78 (patch) (side-by-side diff) | |
tree | 0e337b6c314454614a54234b1ef3b0595ec05471 | |
parent | b8be028a309381b83abe924f5e8e01cf02b121a2 (diff) | |
download | cgit-7d6ee4ee8a2c79802a78bc09c0e1e96a7a82de78.zip cgit-7d6ee4ee8a2c79802a78bc09c0e1e96a7a82de78.tar.gz cgit-7d6ee4ee8a2c79802a78bc09c0e1e96a7a82de78.tar.bz2 |
Include querystring as part of cached filename for repo summary page
When adding support for the h parameter to the summary page (passing current
branch between pages), the builtin cache returned basically random results
for summary page since the cached filename didn't honour the querystring.
This fixes the issue for now, but someday it might be worthwhile to generate
'canonical' filenames in the cache for all pages, i.e. something a bit more
clever than just including the querystring.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,85 +1,87 @@ /* cgit.c: cgi for the git scm * * Copyright (C) 2006 Lars Hjemli * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" const char cgit_version[] = CGIT_VERSION; static int cgit_prepare_cache(struct cacheitem *item) { if (!cgit_repo && cgit_query_repo) { char *title = fmt("%s - %s", cgit_root_title, "Bad request"); cgit_print_docstart(title, item); cgit_print_pageheader(title, 0); cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); cgit_print_docend(); return 0; } if (!cgit_repo) { item->name = xstrdup(fmt("%s/index.html", cgit_cache_root)); item->ttl = cgit_cache_root_ttl; return 1; } if (!cgit_cmd) { - item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root, - cache_safe_filename(cgit_repo->url))); + item->name = xstrdup(fmt("%s/%s/index.%s.html", cgit_cache_root, + cache_safe_filename(cgit_repo->url), + cache_safe_filename(cgit_querystring))); item->ttl = cgit_cache_repo_ttl; } else { item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root, - cache_safe_filename(cgit_repo->url), cgit_query_page, + cache_safe_filename(cgit_repo->url), + cgit_query_page, cache_safe_filename(cgit_querystring))); if (cgit_query_has_symref) item->ttl = cgit_cache_dynamic_ttl; else if (cgit_query_has_sha1) item->ttl = cgit_cache_static_ttl; else item->ttl = cgit_cache_repo_ttl; } return 1; } static void cgit_print_repo_page(struct cacheitem *item) { char *title; int show_search; if (!cgit_query_head) cgit_query_head = cgit_repo->defbranch; if (chdir(cgit_repo->path)) { title = fmt("%s - %s", cgit_root_title, "Bad request"); cgit_print_docstart(title, item); cgit_print_pageheader(title, 0); cgit_print_error(fmt("Unable to scan repository: %s", strerror(errno))); cgit_print_docend(); return; } title = fmt("%s - %s", cgit_repo->name, cgit_repo->desc); show_search = 0; setenv("GIT_DIR", cgit_repo->path, 1); if ((cgit_cmd == CMD_SNAPSHOT) && cgit_repo->snapshots) { cgit_print_snapshot(item, cgit_query_sha1, "zip", cgit_repo->url, cgit_query_name); return; } if (cgit_cmd == CMD_BLOB) { cgit_print_blob(item, cgit_query_sha1, cgit_query_path); return; } show_search = (cgit_cmd == CMD_LOG); cgit_print_docstart(title, item); if (!cgit_cmd) { cgit_print_pageheader("summary", show_search); |