Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1499)

Unified Diff: tools/resources/optimize-png-files.sh

Issue 62873002: Skip corrupted png file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/resources/optimize-png-files.sh
diff --git a/tools/resources/optimize-png-files.sh b/tools/resources/optimize-png-files.sh
index 351e04545e1735aaec7a50b2331db9aa231885f2..50b050e0489eaefa47a195408ce60011d580c7d0 100755
--- a/tools/resources/optimize-png-files.sh
+++ b/tools/resources/optimize-png-files.sh
@@ -18,13 +18,17 @@
readonly ALL_DIRS="
ash/resources
-ui/resources
chrome/app/theme
chrome/browser/resources
chrome/renderer/resources
-webkit/glue/resources
+content/public/android
msw 2013/11/06 21:44:12 Perhaps limit this to content/public/android/java/
oshima 2014/01/09 19:39:25 Done.
+content/renderer/resources
+content/shell/resources
remoting/resources
-remoting/webapp
+ui/resources
+ui/webui/resources
msw 2013/11/06 21:44:12 perhaps limit this to ui/webui/resources/images?
oshima 2014/01/09 19:39:25 Done.
+webkit/glue/resources
+win8/metro_driver/resources
"
# Files larger than this file size (in bytes) will
@@ -44,6 +48,7 @@ readonly LARGE_RANDOM_TRIALS=1
TOTAL_OLD_BYTES=0
TOTAL_NEW_BYTES=0
TOTAL_FILE=0
+CORRUPTED_FILE=0
PROCESSED_FILE=0
declare -a THROBBER_STR=('-' '\\' '|' '/')
@@ -268,7 +273,7 @@ function process_file {
# -rem alla removes all ancillary chunks except for tRNS
pngcrush -d $TMP_DIR -brute -reduce -rem alla $file > /dev/null
- if [ $OPTIMIZE_LEVEL != 0 ]; then
+ if [ -f $TMP_DIR/$name -a $OPTIMIZE_LEVEL != 0 ]; then
msw 2013/11/06 21:44:12 Wow, shell scripting is archaic... I need to look
optimize_size $TMP_DIR/$name
fi
}
@@ -283,13 +288,19 @@ function optimize_file {
local name=$(basename $file)
local old=$(stat -c%s $file)
local tmp_file=$TMP_DIR/$name
+ let TOTAL_FILE+=1
process_file $file
+ if [ ! -e $tmp_file ] ; then
+ let CORRUPTED_FILE+=1
+ echo "The png file ($file) may be corrupted. skipping"
msw 2013/11/06 21:44:12 Interesting, have you encountered this case at all
oshima 2014/01/09 19:39:25 Yes, I had. I think this happened because someone
+ return
+ fi
+
local new=$(stat -c%s $tmp_file)
let diff=$old-$new
let percent=($diff*100)/$old
- let TOTAL_FILE+=1
tput el
if [ $new -lt $old ]; then
@@ -462,11 +473,17 @@ if [ $PROCESSED_FILE == 0 ]; then
echo "Did not find any files (out of $TOTAL_FILE files)" \
"that could be optimized" \
"in $(date -u -d @$SECONDS +%T)s"
+ if [ $CORRUPTED_FILE != 0 ]; then
msw 2013/11/06 21:44:12 nit: just print this after everything else outside
oshima 2014/01/09 19:39:25 Done.
+ echo "Warning: corrupted files found: $CORRUPTED_FILE"
msw 2013/11/06 21:44:12 Would it help to print a list of these file names
oshima 2014/01/09 19:39:25 File names are printed in #297. I added "contact
+ fi
else
let diff=$TOTAL_OLD_BYTES-$TOTAL_NEW_BYTES
let percent=$diff*100/$TOTAL_OLD_BYTES
echo "Processed $PROCESSED_FILE files (out of $TOTAL_FILE files)" \
"in $(date -u -d @$SECONDS +%T)s"
+ if [ $CORRUPTED_FILE != 0 ]; then
+ echo "Warning: corrupted files found: $CORRUPTED_FILE"
+ fi
echo "Result : $TOTAL_OLD_BYTES => $TOTAL_NEW_BYTES bytes" \
"($diff bytes : $percent %)"
fi
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698