From dce9812e5f4b5b2bb520ffc93b9847cb6fcb2075 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 17:48:01 -1000 Subject: Key the cached scan on every setting it uses Two cgitrc files sharing a cache-root read one list, so strict-export and trust-scan-config set in one applied to the other, and a changed setting stayed stale until the list expired. The first request after an upgrade scans again, and the files under the old names are never read. --- tests/t0003-cache.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index d247ae4..e63efa0 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -355,9 +355,9 @@ test_expect_success 'a slot lock that cannot take its key is let go' ' test_dir_is_empty cache3 ' -# A scan is cached in a file named after the hash of its path, so a first -# scan finds out what that name is. The index page is left uncached, which -# makes each request read the list afresh. +# A scan is cached in a file named after a hash of its path and settings, so +# a first scan finds out what that name is. The index page is left uncached, +# which makes each request read the list afresh. test_expect_success 'set up a cached scan of two repositories' ' mkrepo scanned/one 1 && mkrepo scanned/two 1 && @@ -418,4 +418,20 @@ test_expect_success 'a stale lock file reaches neither the scan nor a slot' ' ! grep "STALE-TAIL" replay.out ' +# The cached list is read back as trusted config, so a config that would +# scan differently keeps a list of its own in the same cache-root, here one +# that takes only the repositories carrying an export marker. +test_expect_success 'a config that scans differently keeps its own list' ' + touch scanned/one/.git/export-ok && + { + echo "strict-export=export-ok" && + cat scanrc + } >strictrc && + cgit_rc scanrc "url=" >all.out && + cgit_rc strictrc "url=" >strict.out && + grep ">two" all.out && + grep ">one" strict.out && + ! grep ">two" strict.out +' + test_done -- cgit 2.12.1