]> gitweb.ps.run Git - ps-cgit/blobdiff - cache.c
Add "snapshot-prefix" repo configuration
[ps-cgit] / cache.c
diff --git a/cache.c b/cache.c
index df1b4a31b56dfc9520c57706587f0159bc0b72d1..0901e6e0111ef98b8133bfeb149245e4f0526c6d 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -61,8 +61,9 @@ static int open_slot(struct cache_slot *slot)
        if (bufz)
                bufkeylen = bufz - slot->buf;
 
-       slot->match = bufkeylen == slot->keylen &&
-           !memcmp(slot->key, slot->buf, bufkeylen + 1);
+       if (slot->key)
+               slot->match = bufkeylen == slot->keylen &&
+                   !memcmp(slot->key, slot->buf, bufkeylen + 1);
 
        return 0;
 }
@@ -223,6 +224,12 @@ static int fill_slot(struct cache_slot *slot)
        /* Generate cache content */
        slot->fn();
 
+       /* Make sure any buffered data is flushed to the file */
+       if (fflush(stdout)) {
+               close(tmp);
+               return errno;
+       }
+
        /* update stat info */
        if (fstat(slot->lock_fd, &slot->cache_st)) {
                close(tmp);
@@ -311,7 +318,7 @@ static int process_slot(struct cache_slot *slot)
        /* If the cache slot does not exist (or its key doesn't match the
         * current key), lets try to create a new cache slot for this
         * request. If this fails (for whatever reason), lets just generate
-        * the content without caching it and fool the caller to belive
+        * the content without caching it and fool the caller to believe
         * everything worked out (but print a warning on stdout).
         */