Unverified Commit 6ea89453 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Display download percentage (#485)

parent 0967578f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ rm -f "$TMP"
MSG="Downloading $BASE..."
info "$MSG" && html "$MSG"

/run/progress.sh "$TMP" "Downloading $BASE ([P])..." &
/run/progress.sh "$TMP" "" "Downloading $BASE ([P])..." &
{ wget "$BOOT" -O "$TMP" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :

fKill "progress.sh"
+8 −2
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ escape () {
}

file="$1"
body=$(escape "$2")
total="$2"
body=$(escape "$3")
info="/run/shm/msg.html"

if [[ "$body" == *"..." ]]; then
@@ -24,7 +25,12 @@ do
  if [ -s "$file" ]; then
    bytes=$(du -sb "$file" | cut -f1)
    if (( bytes > 1000 )); then
      size=$(echo "$bytes" | numfmt --to=iec --suffix=B  | sed -r 's/([A-Z])/ \1/')
      if [ -z "$total" ]; then
        size=$(numfmt --to=iec --suffix=B  "$bytes" | sed -r 's/([A-Z])/ \1/')
      else
        size=$(printf '%.1f\n' "$(($bytes*100*100/$total))e-2")
        size="$size%"
      fi
      echo "${body//(\[P\])/($size)}"> "$info"
    fi
  fi