Unverified Commit 29f4cde2 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Show download percentage (#718)

parent c4a00350
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -118,13 +118,14 @@ if [ ! -s "$RDC" ]; then
  info "Install: $MSG" && html "$MSG"

  RD="$TMP/rd.gz"
  SIZE=5394188
  POS="65627648-71021835"
  VERIFY="b4215a4b213ff5154db0488f92c87864"
  LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"

  rm -f "$RD"
  rm -f "$RDC"
  /run/progress.sh "$RD" "$PRG" &
  /run/progress.sh "$RD" "$SIZE" "$PRG" &
  { curl -r "$POS" -sfk -S -o "$RD" "$LOC"; rc=$?; } || :

  fKill "progress.sh"
@@ -141,11 +142,13 @@ if [ ! -s "$RDC" ]; then
  if [ "$SUM" != "$VERIFY" ]; then

    PAT="/install.pat"
    SIZE=379637760

    rm -f "$RD"
    rm -f "$PAT"

    html "$MSG"
    /run/progress.sh "$PAT" "$PRG" &
    /run/progress.sh "$PAT" "$SIZE" "$PRG" &
    { wget "$LOC" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :

    fKill "progress.sh"
@@ -208,13 +211,16 @@ html "$MSG"
PAT="/$BASE.pat"
rm -f "$PAT"

SIZE=0
[[ "$URL" == *"DSM_VirtualDSM_69057.pat" ]] && SIZE=363837333

if [[ "$URL" == "file://"* ]]; then

  cp "${URL:7}" "$PAT"

else

  /run/progress.sh "$PAT" "$PRG" &
  /run/progress.sh "$PAT" "$SIZE" "$PRG" &

  { wget "$URL" -O "$PAT" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :

+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" ] || [[ "$total" == "0" ]]; 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