tazbug rev 132
Bettercount of messages and del file + debug empty messages
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Feb 21 16:39:16 2017 +0100 (2017-02-21) |
parents | 1d0317d8d689 |
children | c2e788b5405d |
files | web/bugs.cgi web/plugins/debug/debug.cgi |
line diff
1.1 --- a/web/bugs.cgi Tue Feb 21 14:36:17 2017 +0100 1.2 +++ b/web/bugs.cgi Tue Feb 21 16:39:16 2017 +0100 1.3 @@ -359,7 +359,7 @@ 1.4 # Write a new message 1.5 new_msg() { 1.6 date=$(date "+%Y-%m-%d %H:%M") 1.7 - msgs=$(ls -1 $bugdir/$id/msg.* | wc -l) 1.8 + msgs=$(ls -1 $bugdir/$id/msg.* | cut -d "." -f 2 | sort -n | tail -n 1) 1.9 count=$(($msgs + 1)) 1.10 if check_auth; then 1.11 USER="$user" 1.12 @@ -726,15 +726,13 @@ 1.13 js_redirection_to "$script?id=$id" 1.14 fi ;; 1.15 *\ id\ *) 1.16 - # Empty deleted messages to keep msg count working. 1.17 header 1.18 html_header 1.19 id="$(GET id)" 1.20 [ "$(GET close)" ] && close_bug 1.21 [ "$(GET open)" ] && open_bug 1.22 [ "$(GET msg)" ] && new_msg 1.23 - [ "$(GET delmsg)" ] && rm -f $bugdir/$id/msg.$(GET delmsg) && \ 1.24 - touch $bugdir/$id/msg.$(GET delmsg) 1.25 + [ "$(GET delmsg)" ] && rm -f $bugdir/$id/msg.$(GET delmsg) 1.26 msgs=$(fgrep MSG= $bugdir/$id/msg.* | wc -l) 1.27 user_box 1.28 . $bugdir/$id/bug.conf
2.1 --- a/web/plugins/debug/debug.cgi Tue Feb 21 14:36:17 2017 +0100 2.2 +++ b/web/plugins/debug/debug.cgi Tue Feb 21 16:39:16 2017 +0100 2.3 @@ -9,14 +9,16 @@ 2.4 html_header 2.5 user_box 2.6 if check_auth && ! admin_user; then 2.7 - gettext "You must be admin to debug" 2.8 - exit 0 2.9 + echo "You must be admin to debug" && exit 0 2.10 fi 2.11 cat << EOT 2.12 <div id="tools"> 2.13 <a href="$script?dashboard">Dashboard</a> 2.14 </div> 2.15 <h2>Debug interface</h2> 2.16 +<p> 2.17 + Check for corrupted config files and empty messages. 2.18 +</p> 2.19 EOT 2.20 # Handle ?debug&del request 2.21 if [ "$(GET del)" ]; then 2.22 @@ -34,13 +36,64 @@ 2.23 do 2.24 if [ $(cat ${bugdir}/${id}/bug.conf | wc -l) != 8 ]; then 2.25 echo "<pre>" 2.26 - echo -e "ERROR: bug ID $id - <a href='?edit=$id'>Edit</a>\ 2.27 - - <a href='?debug&del=$id'>Delete</a>\n" 2.28 + echo -n "ERROR: bug ID $id" 2.29 + # Missing bug.conf 2.30 + if [ ! -f "${bugdir}/${id}/bug.conf" ]; then 2.31 + echo -n " - Missing: bug.conf" 2.32 + fi 2.33 + # Empty bug.conf 2.34 + if [ -s "${bugdir}/${id}/bug.conf" ]; then 2.35 + echo -n " - <a href='?editbug=$id'>Edit</a>" 2.36 + else 2.37 + echo -n " - Empty: bug.conf" 2.38 + fi 2.39 + echo " - <a href='?debug&del=$id'>Delete</a>" 2.40 cat ${bugdir}/${id}/bug.conf 2.41 echo "</pre>" 2.42 + else 2.43 + # Empty values 2.44 + . ${bugdir}/${id}/bug.conf 2.45 + [ -n "$BUG" ] || miss="1" 2.46 + [ -n "$STATUS" ] || miss="1" 2.47 + [ -n "$PRIORITY" ] || miss="1" 2.48 + [ -n "$CREATOR" ] || miss="1" 2.49 + [ -n "$DATE" ] || miss="1" 2.50 + if [ "$miss" ]; then 2.51 + echo "<pre>" 2.52 + echo "ERROR: bug ID $id - Empty variable(s) - <a href='?debug&del=$id'>Delete</a>" 2.53 + cat ${bugdir}/${id}/bug.conf 2.54 + echo "</pre>" 2.55 + fi 2.56 fi 2.57 + unset miss 2.58 done 2.59 echo "$(ls -1 $bugdir | wc -l) bugs scanned" 2.60 2.61 + # Check for messages consistency 2.62 + echo "<h3>Checking for empty messages</h3>" 2.63 + msgs=$(find $bugdir -name msg.* | wc -l) 2.64 + empty=$(find $bugdir -name msg.* -size 0) 2.65 + if [ "$empty" ]; then 2.66 + echo "<pre>" 2.67 + cd ${bugdir} 2.68 + for msg in */msg.* 2.69 + do 2.70 + if [ ! -s "$msg" ]; then 2.71 + # Delete msg ? 2.72 + if [ "$(GET delmsgs)" ]; then 2.73 + echo "Deleting empty message: $(basename $bugdir)/$msg" 2.74 + rm -f ${bugdir}/${msg} 2.75 + else 2.76 + echo "Found empty message: $(basename $bugdir)/$msg" 2.77 + fi 2.78 + fi 2.79 + done 2.80 + if [ ! "$(GET delmsgs)" ]; then 2.81 + echo "--> <a href='?debug&delmsgs'>Delete empty messages</a>" 2.82 + fi 2.83 + echo "</pre>" 2.84 + fi 2.85 + echo "$msgs messages scanned" 2.86 + 2.87 html_footer & exit 0 2.88 fi