The branch, master has been updated via 5c38a10468a40b9b1de4c7d1f9af6284c8d66478 (commit) from ece21fbe9a0c32dba0b9dcdd52849dcef49c5ddb (commit)
- Log ----------------------------------------------------------------- commit 5c38a10468a40b9b1de4c7d1f9af6284c8d66478 Author: Michal Čihař michal@cihar.com Date: Thu May 5 09:17:00 2011 +0200
Write to temprorary file and rename when done.
This avoids problems with demo server when somebody accesses page while this file is being generated.
-----------------------------------------------------------------------
Summary of changes: scripts/remove-incomplete-mo | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/scripts/remove-incomplete-mo b/scripts/remove-incomplete-mo index 83d14ea..02069f9 100755 --- a/scripts/remove-incomplete-mo +++ b/scripts/remove-incomplete-mo @@ -13,20 +13,21 @@ THRESHOLD=50 # # Generated output file # +TMPOUTPUTFILE=libraries/language_stats.inc.php.tmp OUTPUTFILE=libraries/language_stats.inc.php
if [ ! -z "$1" ] ; then THRESHOLD=$1 fi
-echo '<?php' > $OUTPUTFILE -echo '/* Automatically generated file, do not edit! */' >> $OUTPUTFILE -echo '/* Generated by scripts/remove-incomplete-mo */' >> $OUTPUTFILE -echo '' >> $OUTPUTFILE -echo '$GLOBALS["language_stats"] = array (' >> $OUTPUTFILE +echo '<?php' > $TMPOUTPUTFILE +echo '/* Automatically generated file, do not edit! */' >> $TMPOUTPUTFILE +echo '/* Generated by scripts/remove-incomplete-mo */' >> $TMPOUTPUTFILE +echo '' >> $TMPOUTPUTFILE +echo '$GLOBALS["language_stats"] = array (' >> $TMPOUTPUTFILE
check() { - OUTPUTFILE=$2 + TMPOUTPUTFILE=$2 lang=`echo $1 | sed 's@po/(.*).po@\1@'` STATS=`LC_ALL=C msgfmt --statistics -o /dev/null $1 2>&1` if echo $STATS | grep -q ' translated ' ; then @@ -45,7 +46,7 @@ check() { UNTRANSLATED=0 fi PERCENT=`expr 100 * $TRANSLATED / ( $TRANSLATED + $FUZZY + $UNTRANSLATED ) || true` - echo " '$lang' => $PERCENT," >> $OUTPUTFILE + echo " '$lang' => $PERCENT," >> $TMPOUTPUTFILE
if [ $PERCENT -lt $THRESHOLD ] ; then echo "Removing $lang, only $PERCENT%" @@ -54,8 +55,10 @@ check() { }
for x in po/*.po ; do - check $x $OUTPUTFILE + check $x $TMPOUTPUTFILE done
-echo ');' >> $OUTPUTFILE -echo '?>' >> $OUTPUTFILE +echo ');' >> $TMPOUTPUTFILE +echo '?>' >> $TMPOUTPUTFILE + +mv $TMPOUTPUTFILE $OUTPUTFILE
hooks/post-receive