2018-01-23 09:22:38 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
# Copyright 2018 Google Inc.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-01-30 21:08:17 +00:00
|
|
|
BASE_DIR='platform_tools/android/apps/skqp/src/main/assets'
|
|
|
|
PATH_LIST='gmkb skqp'
|
|
|
|
BUCKET=skia-skqp-assets
|
|
|
|
|
2018-01-23 09:22:38 +00:00
|
|
|
EXTANT="$(mktemp "${TMPDIR:-/tmp}/extant.XXXXXXXXXX")"
|
2018-01-30 21:08:17 +00:00
|
|
|
gsutil ls gs://$BUCKET/ | sed "s|^gs://$BUCKET/||" > "$EXTANT"
|
2018-01-23 09:22:38 +00:00
|
|
|
|
|
|
|
upload() {
|
|
|
|
MD5=$(md5sum < "$1" | head -c 32)
|
|
|
|
if ! grep -q "$MD5" "$EXTANT"; then
|
2018-01-30 21:08:17 +00:00
|
|
|
URL="gs://${BUCKET}/$MD5"
|
2018-01-23 19:44:27 +00:00
|
|
|
gsutil cp "$1" "$URL" > /dev/null 2>&1 &
|
2018-01-23 09:22:38 +00:00
|
|
|
fi
|
|
|
|
echo $MD5
|
|
|
|
}
|
|
|
|
|
2018-01-30 21:08:17 +00:00
|
|
|
size() { gsutil du -s gs://$BUCKET | awk '{print $1}'; }
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/../../$BASE_DIR"
|
2018-01-23 09:22:38 +00:00
|
|
|
|
|
|
|
rm -f files.checksum
|
|
|
|
|
|
|
|
FILES="$(mktemp "${TMPDIR:-/tmp}/files.XXXXXXXXXX")"
|
|
|
|
|
|
|
|
: > "$FILES"
|
|
|
|
|
2018-01-30 21:08:17 +00:00
|
|
|
COUNT=$(find $PATH_LIST -type f | wc -l)
|
2018-01-23 09:22:38 +00:00
|
|
|
INDEX=1
|
2018-01-23 19:44:27 +00:00
|
|
|
SHARD_COUNT=32
|
|
|
|
|
2018-01-30 21:08:17 +00:00
|
|
|
SIZE=$(size)
|
|
|
|
find $PATH_LIST -type f | sort | while IFS= read -r FILENAME; do
|
2018-01-23 09:22:38 +00:00
|
|
|
printf '\r %d / %d ' "$INDEX" "$COUNT"
|
|
|
|
if ! [ -f "$FILENAME" ]; then
|
|
|
|
echo error [${FILENAME}] >&2;
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
case "$FILENAME" in *\;*) echo bad filename: $FILENAME >&2; exit 1;; esac
|
|
|
|
MD5=$(upload "$FILENAME")
|
|
|
|
printf '%s;%s\n' "$MD5" "$FILENAME" >> "$FILES"
|
|
|
|
|
2018-01-23 19:44:27 +00:00
|
|
|
if [ $(($INDEX % $SHARD_COUNT)) = 0 ]; then
|
|
|
|
wait
|
|
|
|
fi
|
|
|
|
INDEX=$(( $INDEX + 1))
|
|
|
|
done
|
|
|
|
printf '\rdone \n'
|
2018-01-23 09:22:38 +00:00
|
|
|
upload "$FILES" > files.checksum
|
2018-01-23 19:52:58 +00:00
|
|
|
wait
|
2018-01-23 09:22:38 +00:00
|
|
|
|
2018-01-30 21:08:17 +00:00
|
|
|
D=$(( $(size) - $SIZE ))
|
|
|
|
printf 'Added %d bytes to %s, %d%%\n' $D $BUCKET $(( $D * 100 / $SIZE ))
|
|
|
|
|
|
|
|
rm "$EXTANT"
|