From 6fe19a8af40ed577fb5c842d046ade01a27943e3 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 21 Jul 2026 06:00:58 +0200 Subject: [PATCH] feat: Improve download progress reporting (#1316) --- src/progress.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/progress.sh b/src/progress.sh index 6024b16..a2cdceb 100644 --- a/src/progress.sh +++ b/src/progress.sh @@ -21,7 +21,17 @@ getBytes() { local path="$1" local mode="$2" - local bytes + local bytes="0" + + if [[ "$mode" == "counter" ]]; then + if [ -r "$path" ]; then + read -r bytes < "$path" || bytes="0" + fi + + [[ "$bytes" =~ ^[0-9]+$ ]] || bytes="0" + printf '%s\n' "$bytes" + return 0 + fi if [ ! -s "$path" ] && [ ! -d "$path" ]; then printf '0\n' @@ -134,7 +144,7 @@ if [[ ! "$step_bytes" =~ ^[1-9][0-9]*$ ]]; then fi case "$mode" in - apparent | allocated ) ;; + apparent | allocated | counter ) ;; * ) printf 'Invalid progress mode: %s\n' "$mode" >&2 exit 2