]> git.plutz.net Git - serve0/blob - multitag.sh
great speed improvement, particularly while casting tag selectors
[serve0] / multitag.sh
1 #!/bin/sh
2
3 . "$_EXEC/cgilite/storage.sh"
4 . "$_EXEC/indexmeta.sh"
5
6 for select in $(seq 1 $(POST_COUNT select)); do
7   file="$_DATA/$ITEM/$(POST select $select)"
8   meta="${file%/*}/.index/meta"
9
10   read -r length width height tags comment fn <<-EOF
11         $(meta_info "$file")
12         EOF
13
14   if LOCK "$meta"; then
15     grep -vF "  $fn" "$meta" >"${meta}.tmp"
16     tags="$(UNSTRING "${tags#tags=}" |tr , '\n')"
17
18     for tn in $(seq 1 $(POST_COUNT tag)); do
19       tags="$(printf '%s\n%s' "$tags" "$(POST tag $tn)")"
20     done
21     tags="$(printf '%s\n%s' "$tags" "$(POST newtag |tr -d '\r')")"
22
23     tags="$(printf %s "$tags" |sort -u |tr '\n' ,)"
24     printf '%i\t%i\t%i\ttags=%s\t%s\t%s\n' \
25            "$length" "$width" "$height" \
26            "$(STRING "${tags#,}")" \
27            "$comment" "$fn" \
28     >>"${meta}.tmp"
29     mv "${meta}.tmp" "$meta"
30
31     RELEASE "$meta"
32   fi
33 done