I'm not 100% sure what's causing it, but I think it might have something to do with the fact that I use the parallel API to download all the files (maybe about 100, not too sure) at once. This makes is significantly faster than doing one file at a time, which can take a few minutes rather than a few seconds. As I said, I'm not certain that this is the issue, but it seems the most likely reason.
Essentially, what's happening is http.get is returning nil at random points. Here is a heavily stripped version of the code. If you want to see the whole thing look at the Pastebin file.
local latestReleaseTag = 'v1.2.6' --it gets this dynamically
function downloadBlob(v)
if v.type == 'tree' then
fs.makeDir('/'..v.path)
else
local f = http.get(('https://raw.github.com/oeed/OneOS/'..latestReleaseTag..v.path):gsub(' ','%%20'))
if not f then
error('Downloading failed, try again. '..('https://raw.github.com/oeed/OneOS/'..latestReleaseTag..v.path):gsub(' ','%%20'))
end
local h = fs.open('/'..v.path, 'w')
h.write(f.readAll())
h.close()
end
end
local downloads = {}
for i, v in ipairs(tree) do
table.insert(downloads, function()downloadBlob(v)end)
end
parallel.waitForAll(unpack(downloads))
Any thoughts would be appreciated. It might be of use to take a look at this GitHub issue or the OneOS topic (my signature),
Edited by oeed, 02 October 2014 - 06:42 AM.












