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
}
| grep -m1 -axE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' \
|| meta_file "$file"
else
- printf '0\t0\t0\ttags=\tcomment=\t\r'
+ printf '0\t0\t0\ttags=\tcomment=\t%s\r' "$(meta_name "$file")"
fi
}
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
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