Closed videah closed 6 years ago
I have stumbled upon this once too, but I wasn't able to identify the causes of this error. I'll try to fix this.
Would you please check the return value of fs.pop_dir
I think it may stay in that directory for ever
Also changing the current directory like that inside the loop may destroy the iterator
Consider saving all the folder names and after the whole folder was iterated, iterate on the next one
These are just suggestions not tested and not proved to work, but some ideas that may help debug this. Cheers
fs.pop_dir
returns true if a pop ocurred, false if the stack was empty.
Thanks for the suggestions :)
Debug all the things !
Try something like this:
local _buildFileTree
_buildFileTree = function(dir)
local subDirs = {}
for file in assert(fs.dir()) do
if not file:find("^%.git") then
if fs.is_dir(file) then
subDirs[#subDirs + 1] = file
elseif fs.is_file(file) then
dir[#dir+1] = file
end
end
end
for _, path in ipairs(subDirs) do
local newDir = {}
dir[path] = newDir
assert(fs.change_dir(path))
_buildFileTree(newDir)
assert(fs.pop_dir())
end
end
This has the overhead of needing a secondary loop but will probably work more reliably.
You have to consider that fs.dir
returns an iterator based on a coroutine
and Lua is not that good with coroutines, and handling multiple coroutines at once, switching between them and so on...
This should be fixed now 👍
For some reason, only my font folder, conf.lua, and my readme gets packed. Any reason this is happening?