mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-01 23:44:58 +08:00
fix: Only display non-zero percentage (#1087)
This commit is contained in:
parent
221b0242fa
commit
5577178eeb
@ -21,27 +21,23 @@ if [[ "$body" == *"..." ]]; then
|
||||
body="<p class=\"loading\">${body::-3}</p>"
|
||||
fi
|
||||
|
||||
cluster=$(stat -f "$path" | grep -m 1 "^Block size:" | cut -d':' -f2 | tail -c+2 | cut -d' ' -f1)
|
||||
total=$(( ( ( total + cluster / 2 ) / cluster ) * cluster ))
|
||||
[ -z "$total" ] && total="4096"
|
||||
|
||||
while true
|
||||
do
|
||||
|
||||
if [ ! -s "$path" ] && [ ! -d "$path" ]; then
|
||||
bytes="0"
|
||||
else
|
||||
bytes=$(du -sB 1 "$path" | cut -f1)
|
||||
bytes=$(du -sb "$path" | cut -f1)
|
||||
fi
|
||||
|
||||
if (( bytes > cluster )); then
|
||||
if (( bytes > 4096 )); then
|
||||
if [ -z "$total" ] || [[ "$total" == "0" ]] || [ "$bytes" -gt "$total" ]; then
|
||||
size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/')
|
||||
else
|
||||
size="$(echo "$bytes" "$total" | awk '{printf "%.1f", $1 * 100 / $2}')"
|
||||
size="$size%"
|
||||
fi
|
||||
echo "${body//(\[P\])/($size)}"> "$info"
|
||||
[[ "$size" != "0.0%" ]] && echo "${body//(\[P\])/($size)}"> "$info"
|
||||
fi
|
||||
|
||||
sleep 1 & wait $!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user