Diff options
| -rw-r--r-- | MANUAL.txt | 7 | |
| -rw-r--r-- | source/cgit.c | 2 | |
| -rwxr-xr-x | tests/t0003-cache.sh | 15 |
3 files changed, 20 insertions, 4 deletions
@@ -89,9 +89,10 @@ cache-scan-ttl:: "scan-path", "The cache". cache-size:: - The maximum number of entries in the cgit cache. When set to "0", - caching is disabled. A scan-path caches its result only when this is - defined prior to it. Default value: "0". See also: "The cache". + The maximum number of entries in the cgit cache. When set to "0" or + less, caching is disabled, the scan-path result included. A scan-path + caches its result only when this is defined prior to it. Default value: + "0". See also: "The cache". cache-snapshot-ttl:: Number which specifies the time-to-live, in minutes, for the cached diff --git a/source/cgit.c b/source/cgit.c index dc483ee..81f2b14 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -698,7 +698,7 @@ static void apply_config(const char *name, const char *value) else if (!strcmp(name, "project-list")) ctx.cfg.project_list = cgit_strdup_first_line(cgit_expand_macros(value)); else if (!strcmp(name, "scan-path")) { - if (ctx.cfg.cache_size) + if (ctx.cfg.cache_size > 0) process_cached_repolist(cgit_expand_macros(value)); else scan_tree(cgit_expand_macros(value)); diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index fa72015..0504c88 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -455,4 +455,19 @@ test_expect_success 'a negative cache-scan-ttl never expires the list' ' ! grep "^repo.url=kept$" "cache5/$scanned_rc" ' +# A cache-size below zero turns the page cache off, and the scan with it, so +# the cache directory stays empty. +test_expect_success 'a negative cache-size leaves the scan uncached' ' + { + echo "virtual-root=/" && + echo "cache-root=$PWD/cache-negative" && + echo "cache-size=-1" && + echo "scan-path=$PWD/scanned" + } >negativerc && + rm -rf cache-negative && mkdir cache-negative && + cgit_rc negativerc "url=" >tmp && + grep ">one</a>" tmp && + test_dir_is_empty cache-negative +' + test_done |
