From 00c168ce179e05c238cb598fab44887404f6b25c Mon Sep 17 00:00:00 2001 From: z4yx Date: Sun, 22 Mar 2020 13:20:10 +0800 Subject: [PATCH] calculate the size of pybombs repo --- pybombs.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pybombs.sh b/pybombs.sh index 542a256..3de75e6 100755 --- a/pybombs.sh +++ b/pybombs.sh @@ -14,8 +14,19 @@ function pybombs_mirror() { cp ${PYBOMBS_MIRROR_SCRIPT_PATH}/ignore.urls ${TUNASYNC_WORKING_DIR}/ ${PYBOMBS_MIRROR_SCRIPT_PATH}/pybombs-mirror.sh } +function calculate_size() { + total_size=0 + for repo in "${TUNASYNC_WORKING_DIR}"/git/*; do + sz=$(git -C "$repo" count-objects -v|grep -Po '(?<=size-pack: )\d+') + total_size=$(($total_size+1024*$sz)) + done + sz=$(du -sb "${TUNASYNC_WORKING_DIR}/wget"|cut -f1) + total_size=$(($total_size+$sz)) + echo "Total size is" $(numfmt --to=iec $total_size) +} PYBOMBS_MIRROR_SCRIPT_PATH="${PYBOMBS_MIRROR_SCRIPT_PATH:-"/opt/pybombs-mirror"}" MIRROR_BASE_URL="${MIRROR_BASE_URL:-"https://pybombs.tuna.tsinghua.edu.cn"}" pybombs_mirror +calculate_size