s4

changeset 407:4d912c2d48df

Little bit spped up the judgement on necessity of cache re-creation
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 09 Feb 2017 11:20:10 +0900
parents 1af18eeeffb3
children 138a0c6b09a7
files s4-blog.sh
diffstat 1 files changed, 13 insertions(+), 19 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Thu Feb 09 09:38:51 2017 +0900
     1.2 +++ b/s4-blog.sh	Thu Feb 09 11:20:10 2017 +0900
     1.3 @@ -220,37 +220,32 @@
     1.4    ON a.id=s.id;
     1.5  EOF
     1.6    while IFS='|' read id edit notify uid uname icon aid tm new hte imgids; do
     1.7 -    cachedir="$td/$id"; test -d "$cachedir" || mkdir -p "$cachedir"
     1.8 -    cachefile="$cachedir/$id.row"
     1.9 -    stampfile="$cachedir/$id.stamp"
    1.10 +    cachefile="$td/$id.row.html"
    1.11 +    stampfile="$td/$id.row.stamp"
    1.12  
    1.13      # First, check the availability of user-icon.
    1.14      # If not existent, clear and reset row cache by rm $stampfile
    1.15 -    if [ -n "$icon" -a -s "$icon" ]; then
    1.16 -      icfn=`echo "$icon"|htmlescape`
    1.17 -      picon="<p class=\"proficon\"><a href=\"$hlink+$uid\"><img src=\"$icfn\"></a></p>"
    1.18 -    else
    1.19 -      picon=""
    1.20 -      if [ -n "$icon" ]; then
    1.21 -	echo "DELETE FROM user_s WHERE key='$iconcachekey' AND
    1.22 -	    	        val=`sqlquotestr \"$icon\"`;" >> $iconcleaner
    1.23 -      fi
    1.24 -      rm -f "$stampfile"
    1.25 -      unset stampfile	# No icon-image, do not construct row-cache
    1.26 +    if [ ! -s "$icon" ]; then
    1.27 +      rm -f "$stampfile"; unset stampfile
    1.28      fi
    1.29 -
    1.30      if test -s "$stampfile" &&
    1.31  	  test -s "$cachefile" &&
    1.32  	  { ts=`cat "$stampfile"`; test -n "$ts"; } &&
    1.33  	  test "$ts" '>' "$tm"; then
    1.34 -	#sed "/<td class=/s/__NEWCLS__/$new/" $cachefile
    1.35 -	#continue			# And continue to next loop
    1.36        : Nothing to do
    1.37      else
    1.38        {		######## New ROW creation begins here ######## >$cachefile
    1.39  	nt="<label style=\"font-size: 70%;\"><input type=\"checkbox\"
    1.40  	 name=\"notifyto\" value=\"$uid\">返信通知送信</label>"
    1.41  	tdcls="__NEWCLS__repatt"
    1.42 +	if [ -s "$icon" ]; then
    1.43 +	  icfn=`echo "$icon"|htmlescape`
    1.44 +	  picon="<p class=\"proficon\"><a href=\"$hlink+$uid\"><img src=\"$icfn\"></a></p>"
    1.45 +	else
    1.46 +	  echo "DELETE FROM user_s WHERE key='$iconcachekey' AND
    1.47 +	       val=`sqlquotestr \"$icon\"`;" >> $iconcleaner
    1.48 +	  picon=""
    1.49 +	fi
    1.50  
    1.51  	cat<<EOF
    1.52  <tr id="$id">
    1.53 @@ -267,7 +262,7 @@
    1.54  	  fn=`echo "${i#*:}"|unhexize`
    1.55  	  fnb=$fn"(${sz})"
    1.56  	  case "$fn" in
    1.57 -	    *.[Pp][Nn][Gg]|*.[Jj][Pp][Gg]|*.[Jj][Pp][Ee][Gg]|*.[Gg][Ii][Ff])
    1.58 +	    *.[Pp][Nn][Gg]|*.[Jj][Pp][Gg]|*.[Jj][Pp][Ee][Gg]|*.[GgTt][Ii][Ff])
    1.59  	      #  fmt=${fn##*.}	# convert - jpg:- is slow...why
    1.60  	      case "$fn" in
    1.61  		*.[Pp][Nn][Gg])	fmt=png ;;
    1.62 @@ -299,7 +294,6 @@
    1.63  		    | sed -e 's/\(..\)/%\1/g' \
    1.64  	    		  -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \
    1.65  			  -e "s|\$|\">$fnb</a>|"
    1.66 -		# [ -d $td ] || mkdir -p "$td"
    1.67  		unset stampfile # img data stream is not suitable to cache
    1.68  		echo $tm > $tsfile
    1.69  	      fi