X-Git-Url: http://git.plutz.net/?p=serve0;a=blobdiff_plain;f=indexmeta.sh;h=2da085f9a0bf86fcdb630f8fd98443df7d99c423;hp=00741d44881793000fce5b4f2e24142d8e6cf51f;hb=608e267413cf7f8399cacbbfc4269d3c3820a3aa;hpb=1b79a90402ee3fe450575085470b3ec6d084d78b diff --git a/indexmeta.sh b/indexmeta.sh index 00741d4..2da085f 100644 --- a/indexmeta.sh +++ b/indexmeta.sh @@ -52,9 +52,9 @@ meta_purge(){ name="$(meta_name "$file")" if [ -d "${meta%/meta}" ] && LOCK "$meta"; then - grep -avF " ${name}" "$meta" >"$meta.tmp" - grep -aF " ${name}" "$meta" >>"$meta.trash" - mv "$meta.tmp" "$meta" + grep -avF " ${name}" "$meta" >"${meta}.tmp" + grep -aF " ${name}" "$meta" >>"${meta}.trash" + mv "${meta}.tmp" "$meta" RELEASE "$meta" fi } @@ -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,16 +89,18 @@ 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 grep -qF " $(meta_name "$v")" "$meta" \ || meta_line "$v" done >>"$meta" - rm "$meta.ref" + sort -u "$meta" >"$meta.ref" + mv "$meta.ref" "$meta" + touch "$metat" RELEASE "$meta" fi