]> 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 1be1ea4393d50266ec623e7ff5bb38d9e7008795..0ffa502c119ae33deaac913eabb742679cf4fe18 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -1,8 +1,16 @@
+/* cache.c: cache management
+ *
+ * Copyright (C) 2006 Lars Hjemli
+ *
+ * Licensed under GNU General Public License v2
+ *   (see COPYING for full license text)
+ */
+
 #include "cgit.h"
 
 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));
@@ -22,6 +30,10 @@ int cache_lookup(struct cacheitem *item)
                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;