From 83ae7baa92d4bf2010666435813bb965f7c71561 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 4 Jun 2019 17:37:36 +0200 Subject: [PATCH] improved update heuristics --- index.cgi | 2 +- indexmeta.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/index.cgi b/index.cgi index 62e495a..a33211d 100755 --- a/index.cgi +++ b/index.cgi @@ -26,7 +26,7 @@ case $ACTION in SET_COOKIE +$((86400 * 90)) mode="$(POST mode |grep -m1 -axE 'browse|index' || printf browse)" SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -axE 'yes' || printf no)" SET_COOKIE +$((86400 * 90)) downscale="$(POST downscale |grep -m1 -axE 'yes' || printf no)" - [ "$(POST index)" = "update" ] && touch -cd @0 "${_DATA}/.index/meta" + [ "$(POST index)" = "update" ] && touch -cd @0 "${_DATA}/.index/meta.time" REDIRECT "$(POST ref)" ;; bookmark) diff --git a/indexmeta.sh b/indexmeta.sh index fb893e1..2da085f 100644 --- a/indexmeta.sh +++ b/indexmeta.sh @@ -76,6 +76,9 @@ meta_dir(){ local dir meta v dir="${1}" meta="${dir}/.index/meta" + metat="${dir}/.index/meta.time" + + [ -f "$metat" ] || touch -d @0 "$metat" if [ -d "$dir/.index" -a \! -f "$meta" ] && LOCK "$meta"; then touch "$meta" # preliminary touch to prevent concurrent generators @@ -86,9 +89,9 @@ meta_dir(){ done >"$meta" RELEASE "$meta" - elif [ -d "$dir/.index" -a "$dir" -nt "$meta" ] && LOCK "$meta"; then + elif [ -d "$dir/.index" -a "$dir" -nt "$metat" ] && LOCK "$meta"; then cp -p "$meta" "$meta.ref"; touch "$meta" - find "$dir" -type f -newer "$meta.ref" \ + find "$dir" -type f -newer "$metat" \ -mindepth 1 -maxdepth 1 \ | grep -aE "$file_pattern" \ | while read -r v; do @@ -97,6 +100,7 @@ meta_dir(){ done >>"$meta" sort -u "$meta" >"$meta.ref" mv "$meta.ref" "$meta" + touch "$metat" RELEASE "$meta" fi -- 2.39.2