|
12345678910111213141516 |
- #!/bin/bash
- # Check how much of an upload made it into the item yet (vs. how much is stuck in the S3 queue if you also watch the upload process)
- # Usage: ia-upload-progress IA_IDENTIFIER [FILES]
- # If no files are specified, all WARCs in the current directory are used.
- identifier=$1
- shift
- files=("$@")
- if [[ ${#files[@]} -eq 0 ]]
- then
- files=(*.warc.gz)
- fi
- scriptpath="$(cd "$(dirname "$0")"; pwd -P)"
-
- uploaded=$(ia metadata "${identifier}" | grep -Po '("source"\s*:\s*"original",[^}]*"size"\s*:\s*"\K\d+|"size"\s*:\s*"\K\d+(?="\s*,[^}]*"source"\s*:\s*"original"))' | awk '{sum+=$1} END {printf "%.0f\n", sum}')
- localSize=$(du -bc "${files[@]}" | tail -1 | cut -f1)
- echo "Uploaded $("${scriptpath}/format-size" <<<"${uploaded}") of $("${scriptpath}/format-size" <<<"${localSize}") ($(awk '{ printf "%.1f", 100 * ($1 / $2); }' <<<"${uploaded} ${localSize}") %)"
|