From 3a41ff8d0cbfd0a7891697acf162f0b5800550ce Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 18:26:03 -1000 Subject: Keep a scan with a negative ttl for good "The cache" promises that a negative ttl never expires, but no age was ever below a negative cache-scan-ttl, so every request started a background rescan. --- tests/t0003-cache.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index e63efa0..fa72015 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -434,4 +434,25 @@ test_expect_success 'a config that scans differently keeps its own list' ' ! grep ">two" strict.out ' +# A negative ttl never expires, so a list however old is served and kept. A +# rebuild runs in a child holding the request's copy of fd 9, so cat reaching +# the end of that pipe means any rebuild is done, as the positive ttl after +# it shows. +test_expect_success 'a negative cache-scan-ttl never expires the list' ' + { + echo "cache-scan-ttl=-1" && + cat scanrc + } >foreverrc && + { + echo "repo.url=kept" && + echo "repo.path=$PWD/scanned/one/.git" + } >>"cache5/$scanned_rc" && + touch -t 200001010000 "cache5/$scanned_rc" && + cgit_rc foreverrc "url=" 9>&1 >forever.out | cat && + grep ">kept" forever.out && + grep "^repo.url=kept$" "cache5/$scanned_rc" && + cgit_rc scanrc "url=" 9>&1 >/dev/null | cat && + ! grep "^repo.url=kept$" "cache5/$scanned_rc" +' + test_done -- cgit 2.12.1