Added util.getFriendlySize() (#3381)

* Added util.getFriendlySize()

* Allow for GB
This commit is contained in:
poire-z
2017-10-20 17:48:32 +02:00
committed by Frans de Jonge
parent 87a86e0dc1
commit c15915a4ee
4 changed files with 21 additions and 25 deletions

View File

@@ -133,15 +133,7 @@ end
-- DB management
function BookInfoManager:getDbSize()
local file_size = lfs.attributes(self.db_location, "size") or 0
local sstr
if file_size > 1024*1024 then
sstr = string.format("%4.1f MB", file_size/1024/1024)
elseif file_size > 1024 then
sstr = string.format("%4.1f KB", file_size/1024)
else
sstr = string.format("%d B", file_size)
end
return sstr
return require("util").getFriendlySize(file_size)
end
function BookInfoManager:createDB()