Mercurial > hgrepos > hgweb.cgi > 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 wrap: on
line diff
--- a/s4-blog.sh Thu Feb 09 09:38:51 2017 +0900 +++ b/s4-blog.sh Thu Feb 09 11:20:10 2017 +0900 @@ -220,37 +220,32 @@ ON a.id=s.id; EOF while IFS='|' read id edit notify uid uname icon aid tm new hte imgids; do - cachedir="$td/$id"; test -d "$cachedir" || mkdir -p "$cachedir" - cachefile="$cachedir/$id.row" - stampfile="$cachedir/$id.stamp" + cachefile="$td/$id.row.html" + stampfile="$td/$id.row.stamp" # First, check the availability of user-icon. # If not existent, clear and reset row cache by rm $stampfile - if [ -n "$icon" -a -s "$icon" ]; then - icfn=`echo "$icon"|htmlescape` - picon="<p class=\"proficon\"><a href=\"$hlink+$uid\"><img src=\"$icfn\"></a></p>" - else - picon="" - if [ -n "$icon" ]; then - echo "DELETE FROM user_s WHERE key='$iconcachekey' AND - val=`sqlquotestr \"$icon\"`;" >> $iconcleaner - fi - rm -f "$stampfile" - unset stampfile # No icon-image, do not construct row-cache + if [ ! -s "$icon" ]; then + rm -f "$stampfile"; unset stampfile fi - if test -s "$stampfile" && test -s "$cachefile" && { ts=`cat "$stampfile"`; test -n "$ts"; } && test "$ts" '>' "$tm"; then - #sed "/<td class=/s/__NEWCLS__/$new/" $cachefile - #continue # And continue to next loop : Nothing to do else { ######## New ROW creation begins here ######## >$cachefile nt="<label style=\"font-size: 70%;\"><input type=\"checkbox\" name=\"notifyto\" value=\"$uid\">返信通知送信</label>" tdcls="__NEWCLS__repatt" + if [ -s "$icon" ]; then + icfn=`echo "$icon"|htmlescape` + picon="<p class=\"proficon\"><a href=\"$hlink+$uid\"><img src=\"$icfn\"></a></p>" + else + echo "DELETE FROM user_s WHERE key='$iconcachekey' AND + val=`sqlquotestr \"$icon\"`;" >> $iconcleaner + picon="" + fi cat<<EOF <tr id="$id"> @@ -267,7 +262,7 @@ fn=`echo "${i#*:}"|unhexize` fnb=$fn"(${sz})" case "$fn" in - *.[Pp][Nn][Gg]|*.[Jj][Pp][Gg]|*.[Jj][Pp][Ee][Gg]|*.[Gg][Ii][Ff]) + *.[Pp][Nn][Gg]|*.[Jj][Pp][Gg]|*.[Jj][Pp][Ee][Gg]|*.[GgTt][Ii][Ff]) # fmt=${fn##*.} # convert - jpg:- is slow...why case "$fn" in *.[Pp][Nn][Gg]) fmt=png ;; @@ -299,7 +294,6 @@ | sed -e 's/\(..\)/%\1/g' \ -e "s|^|<a href=\"$catlink+$mrid\"><img src=\"data:image/$fmt,|" \ -e "s|\$|\">$fnb</a>|" - # [ -d $td ] || mkdir -p "$td" unset stampfile # img data stream is not suitable to cache echo $tm > $tsfile fi