mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-17 06:23:00 +02:00
general-functions.pl: formatBytes() Fix computing the correct unit.
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org> Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
This commit is contained in:
committed by
Arne Fitzenreiter
parent
e1cc1e6cb9
commit
25932be3e3
@@ -1272,14 +1272,14 @@ sub formatBytes {
|
||||
|
||||
# Loop through the array of units.
|
||||
foreach my $element (@units) {
|
||||
# Assign current processed element to unit.
|
||||
$unit = $element;
|
||||
|
||||
# Break loop if the bytes are less than the next unit.
|
||||
last if $bytes < 1024;
|
||||
|
||||
# Divide bytes amount with 1024.
|
||||
$bytes /= 1024;
|
||||
|
||||
# Assign current processed element to unit.
|
||||
$unit = $element;
|
||||
}
|
||||
|
||||
# Return the divided and rounded bytes count and the unit.
|
||||
|
||||
Reference in New Issue
Block a user