scripts/lua/modules/lua_utils.lua: fix precision of bytes

This commit lets the bytesToSize() function perform the requested
rounding even when returning bytes. This also fixes the symbol
used in that case as a measure unit so that it is consistent.
This commit is contained in:
Arianna Avanzini 2015-05-25 08:57:49 +02:00
parent 3afe49b8e6
commit 317c9b5d54

View file

@ -354,7 +354,7 @@ function bytesToSize(bytes)
terabyte = gigabyte * 1024;
if((bytes >= 0) and (bytes < kilobyte)) then
return bytes .. " Bytes";
return round(bytes, precision) .. " B";
elseif((bytes >= kilobyte) and (bytes < megabyte)) then
return round(bytes / kilobyte, precision) .. ' KB';
elseif((bytes >= megabyte) and (bytes < gigabyte)) then
@ -364,7 +364,7 @@ function bytesToSize(bytes)
elseif(bytes >= terabyte) then
return round(bytes / terabyte, precision) .. ' TB';
else
return bytes .. ' B';
return round(bytes, precision) .. ' B';
end
end