]> gitweb.ps.run Git - ps-cgit/blobdiff - cache.c
Fix cache algorithm loophole
[ps-cgit] / cache.c
diff --git a/cache.c b/cache.c
index b034c480e0d9866de93bfa3866abda0cb0bd7df5..0ffa502c119ae33deaac913eabb742679cf4fe18 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -10,7 +10,7 @@
 
 const int NOLOCK = -1;
 
 
 const int NOLOCK = -1;
 
-int cache_lookup(struct cacheitem *item)
+void cache_prepare(struct cacheitem *item)
 {
        if (!cgit_query_repo) {
                item->name = xstrdup(fmt("%s/index.html", cgit_cache_root));
 {
        if (!cgit_query_repo) {
                item->name = xstrdup(fmt("%s/index.html", cgit_cache_root));
@@ -30,6 +30,10 @@ int cache_lookup(struct cacheitem *item)
                else
                        item->ttl = cgit_cache_repo_ttl;
        }
                else
                        item->ttl = cgit_cache_repo_ttl;
        }
+}
+
+int cache_exist(struct cacheitem *item)
+{
        if (stat(item->name, &item->st)) {
                item->st.st_mtime = 0;
                return 0;
        if (stat(item->name, &item->st)) {
                item->st.st_mtime = 0;
                return 0;