Hal Canary | 23fda7a | 2018-01-23 09:22:38 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # Copyright 2018 Google Inc. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | set -e |
| 8 | |
| 9 | EXTANT="$(mktemp "${TMPDIR:-/tmp}/extant.XXXXXXXXXX")" |
| 10 | gsutil ls gs://skia-skqp-assets/ | sed 's|^gs://skia-skqp-assets/||' > "$EXTANT" |
| 11 | |
| 12 | upload() { |
| 13 | MD5=$(md5sum < "$1" | head -c 32) |
| 14 | if ! grep -q "$MD5" "$EXTANT"; then |
| 15 | URL="gs://skia-skqp-assets/$MD5" |
Hal Canary | 8d4a9f0 | 2018-01-23 14:44:27 -0500 | [diff] [blame] | 16 | gsutil cp "$1" "$URL" > /dev/null 2>&1 & |
Hal Canary | 23fda7a | 2018-01-23 09:22:38 +0000 | [diff] [blame] | 17 | fi |
| 18 | echo $MD5 |
| 19 | } |
| 20 | |
| 21 | cd "$(dirname "$0")/../../platform_tools/android/apps/skqp/src/main/assets" |
| 22 | |
| 23 | rm -f files.checksum |
| 24 | |
| 25 | FILES="$(mktemp "${TMPDIR:-/tmp}/files.XXXXXXXXXX")" |
| 26 | |
| 27 | : > "$FILES" |
| 28 | |
| 29 | COUNT=$(find * -type f | wc -l) |
| 30 | INDEX=1 |
Hal Canary | 8d4a9f0 | 2018-01-23 14:44:27 -0500 | [diff] [blame] | 31 | SHARD_COUNT=32 |
| 32 | |
Hal Canary | 23fda7a | 2018-01-23 09:22:38 +0000 | [diff] [blame] | 33 | find * -type f | sort | while IFS= read -r FILENAME; do |
| 34 | printf '\r %d / %d ' "$INDEX" "$COUNT" |
Hal Canary | 23fda7a | 2018-01-23 09:22:38 +0000 | [diff] [blame] | 35 | if ! [ -f "$FILENAME" ]; then |
| 36 | echo error [${FILENAME}] >&2; |
| 37 | exit 1; |
| 38 | fi |
| 39 | case "$FILENAME" in *\;*) echo bad filename: $FILENAME >&2; exit 1;; esac |
| 40 | MD5=$(upload "$FILENAME") |
| 41 | printf '%s;%s\n' "$MD5" "$FILENAME" >> "$FILES" |
Hal Canary | 23fda7a | 2018-01-23 09:22:38 +0000 | [diff] [blame] | 42 | |
Hal Canary | 8d4a9f0 | 2018-01-23 14:44:27 -0500 | [diff] [blame] | 43 | if [ $(($INDEX % $SHARD_COUNT)) = 0 ]; then |
| 44 | wait |
| 45 | fi |
| 46 | INDEX=$(( $INDEX + 1)) |
| 47 | done |
| 48 | printf '\rdone \n' |
Hal Canary | 23fda7a | 2018-01-23 09:22:38 +0000 | [diff] [blame] | 49 | upload "$FILES" > files.checksum |
Hal Canary | 3da15bb | 2018-01-23 14:52:58 -0500 | [diff] [blame] | 50 | wait |
Hal Canary | 23fda7a | 2018-01-23 09:22:38 +0000 | [diff] [blame] | 51 | |
| 52 | rm "$FILES" "$EXTANT" |