diff --git a/src/lua/fio.lua b/src/lua/fio.lua index cb224f3d0fb3..4692e102665a 100644 --- a/src/lua/fio.lua +++ b/src/lua/fio.lua @@ -364,7 +364,11 @@ fio.mktree = function(path, mode) local stat = fio.stat(current_dir) if stat == nil then local st, err = fio.mkdir(current_dir, mode) - if err ~= nil then + -- fio.stat() and fio.mkdir() above are separate calls + -- and a file system may be changed between them. So + -- if the error here is due to an existing directory, + -- the function should not report an error. + if err ~= nil and not fio.path.is_dir(current_dir) then return false, string.format("Error creating directory %s: %s", current_dir, tostring(err)) end