X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=indexmeta.sh;h=43e360d2bfcfab9f4cc7ea2016b971f981239227;hb=61933758148caee332ab0ca95f1a2feccd612b5e;hp=aad3fc1433990ee4f0822dc4d9b54fdd26420ed0;hpb=d23cbb70e8cb096b7ef7c32e6cac083257cf1f31;p=serve0 diff --git a/indexmeta.sh b/indexmeta.sh index aad3fc1..43e360d 100644 --- a/indexmeta.sh +++ b/indexmeta.sh @@ -15,6 +15,7 @@ meta_name() { meta_line() { local video l w h video="$1" + [ "${video%.part}" = "$video" -a -s "$video" ] || return 0 read l h w <<__EOF $(printf '' \ @@ -52,9 +53,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 +77,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 @@ -84,19 +88,19 @@ meta_dir(){ | while read -r v; do meta_line "$v" done >"$meta" + touch "$metat" RELEASE "$meta" - elif [ -d "$dir/.index" -a "$dir" -nt "$meta" ] && LOCK "$meta"; then - cp -p "$meta" "$meta.ref"; touch "$meta" - find "$dir" -type f -newer "$meta.ref" \ + elif [ -d "$dir/.index" -a "$dir" -nt "$metat" ] && LOCK "$meta"; then + touch "$meta" + 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" - sort -u "$meta" >"$meta.ref" - mv "$meta.ref" "$meta" + touch "$metat" RELEASE "$meta" fi