]> git.plutz.net Git - serve0/commitdiff
different caching behaviour for tags and tagcategories
authorPaul Hänsch <paul@plutz.net>
Mon, 14 Feb 2022 22:05:41 +0000 (23:05 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 14 Feb 2022 22:05:41 +0000 (23:05 +0100)
multitag.sh
widgets.sh

index 674983ad626431746700d091655fa305ce7dfc68..d928e459d8596de0e23def22731d7e44682e83cb 100755 (executable)
@@ -2,6 +2,7 @@
 
 . "$_EXEC/db_meta.sh"
 . "$_EXEC/cgilite/session.sh" nocookie
+. "$_EXEC/widgets.sh"
 
 newtags=''
 for tn in $(seq 1 $(POST_COUNT tag)); do
@@ -47,3 +48,11 @@ for select in $(seq 1 $(POST_COUNT select)); do
     update_meta "$META_NAME" tags="${tags}"
   fi
 done
+
+( if [ $(POST_COUNT select) -gt 0 ]; then
+    taglist >"$c_tags.$$"
+    tclist "$(cat "$c_tags.$$")" >"$c_tagcategories.$$"
+    mv -- "$c_tags.$$" "$c_tags"
+    mv -- "$c_tagcategories.$$" "$c_tagcategories"
+  fi &
+) &
index 4d42c41d0bc73a0cd65f164033f5d295e10cddcd..26d755fb4301e3676b973cad186edfc41f13af8f 100755 (executable)
@@ -11,27 +11,35 @@ w_refuri="$(URL "$PATH_INFO")?$(HTML "$QUERY_STRING")"
 w_str_s="$(STRING "$SEARCH")"
 w_str_f="$(STRING "$FILTER")"
 
-c_tags="$_DATA/.index/tags.cache"; c_tagcategories="$_DATA/.index/tagcategories.cache"
-if [ ! -s "$c_tags" -o ! -s "$c_tagcategories" ] \
-   || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$c_tags")" ]
-  then
-  w_tags="$(
-    list_meta |sed -E '
-      s;^.*\ttags=([^\t]*)\t.*$;\1;;
-      s;,;\n;g;
-    ' \
-    | sort |uniq -c |sort -rn |sed -E 's;^ *[0-9]+ ;;;' \
-    | UNSTRING | HTML \
-    | sed -E 's;&#x0A\;;\n;g; s;\n+;\n;g;'
-  )"
-  w_tagcategories="$(printf %s "$w_tags" | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u )"
-  printf %s "$w_tags" >"$c_tags"
-  printf %s "$w_tagcategories" >"$c_tagcategories"
-else
-  w_tags="$(cat "$c_tags")"
-  w_tagcategories="$(cat "$c_tagcategories")"
+taglist(){
+  list_meta |sed -E '
+    s;^.*\ttags=([^\t]*)\t.*$;\1;;
+    s;,;\n;g;
+  ' \
+  | sort |uniq -c |sort -rn |sed -E 's;^ *[0-9]+ ;;;' \
+  | UNSTRING | HTML \
+  | sed -E 's;&#x0A\;;\n;g; s;\n+;\n;g;'
+}
+
+tclist(){
+  printf %s "$*" \
+  | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' \
+  |sort -u
+}
+
+c_tags="$_DATA/.index/tags.cache";
+if [ ! -s "$c_tags" ]; then
+  taglist >"$c_tags.$$"
+  mv "$c_tags.$$" "$c_tags"
 fi
+w_tags="$(cat "$c_tags")"
 
+c_tagcategories="$_DATA/.index/tagcategories.cache"
+if [ ! -s "$c_tagcategories" ]; then
+  tclist "$w_tags" >"$c_tagcategories.$$"
+  mv "$c_tagcategories.$$" "$c_tagcategories"
+fi
+w_tagcategories="$(cat "$c_tagcategories")"
 
 [ "$ORDER" = Name   ] && w_coname=checked
 [ "$ORDER" = Date   ] && w_codate=checked
@@ -114,7 +122,7 @@ w_search(){
 w_prefs(){
   local tm tf td
 
-  tm=''; [ "$(COOKIE mode)" = index ] && tm=' '
+  tm=''; [ "$(COOKIE mode)" = browse ] && tm=' '
   tf=''; [ "$(COOKIE fakemp4)" = yes ] && tf=checked
   td=''; [ "$(COOKIE downscale)" = yes ] && td=checked
 
@@ -124,8 +132,8 @@ w_prefs(){
          [hidden "ref" "${w_refuri}"]
          [label for=prefs_ps Pagesize]
          [input #prefs_ps type=number name=pagesize value="${LISTSIZE}"][br]
-         [radio "mode" "browse" ${tm:-checked=checked} #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
-         [radio "mode" "index" ${tm:+checked=checked} #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
+         [radio "mode" "browse" ${tm:+checked=checked} #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
+         [radio "mode" "index"  ${tm:-checked=checked} #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
          [checkbox "fakemp4" "yes" ${tf} #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file type][br]
          [checkbox "downscale" "yes" ${td} #prefs_downscale] [label for=prefs_downscale Prefer downscale to 480p][br]
          [submit "index" "update" Force Index Update][br]