Centralize LÖVE downloads

This commit is contained in:
Antonin Décimo
2019-07-15 18:53:49 +02:00
parent 6ea2462d52
commit 6b7ff6de7d
3 changed files with 24 additions and 16 deletions

View File

@@ -155,4 +155,22 @@ function utils.io.err(string)
end
--[[ DOWNLOAD ]]--
--- Downloads and optionally caches a file. Will assert on download
-- failure.
-- @string url the document to download
-- @string dest where to write it
-- @bool cacheable cache it or not
function utils.download(url, dest, cacheable)
if not fs.exists(dest) then
local ok, msg = fs.download(url, dest, cacheable)
if not ok then
utils.io.err("Tried to download "..url.." to "..dest.."\n")
assert(ok, msg)
end
end
end
return utils