wget fails when downloading empty files
SquidDev opened this issue ยท 4 comments
When downloading an empty file, wget prints "Success" but fails to actually save the file. This is because readAll()
returns nil
when reading empty files:
local contents = http.get("https://raw.githubusercontent.com/xiondisc/CC-Test/5c4648b5bba5630953e3d09f08bc199fd15bf69c/TurtleTest/turtleTest.lua", nil, true)
print(contents.readAll()) -- nil!
contents.close()
This is correct behaviour (judging by what PUC Lua does), so we should fix this on the wget
side.
While we're documenting wget bugs, looks like we also fail to do any error handling on fs.open
calls:
Should probably do something like:
local file, err = ...
if not file then
printError(err)
return
end
What would you suggest to print out if the responce.readAll()
is nil?
Remote file is empty.
?
Got empty reponse.
?