1
0
mirror of https://github.com/natnat-mc/moonbuild synced 2026-05-11 21:01:14 +02:00

fixed mkdirs sometimes failing due to race condition when multiprocess builds are running

This commit is contained in:
Codinget
2021-01-10 22:19:10 +01:00
parent cd9b0ab159
commit 57126a7973
2 changed files with 28 additions and 9 deletions
+19 -6
View File
@@ -973,14 +973,27 @@ mkdir = function(dir)
end
local mkdirs
mkdirs = function(dir)
if isdir(dir) then
return
end
if exists(dir) then
error("Can't mkdirs " .. tostring(dir) .. ": file exists")
do
local attr = attributes(normalizepath(dir))
if attr then
if attr.mode == 'directory' then
return
end
error("Can't mkdirs " .. tostring(dir) .. ": file exists")
end
end
mkdirs(parent(dir))
return mkdir(dir)
if not (pcall(function()
return actualmkdir(dir)
end)) then
clearentry(parent(dir))
clearentry(dir)
if not (isdir(dir)) then
error("Failed to mkdirs " .. tostring(dir) .. ": last mkdir failed")
end
end
clearentry(parent(dir))
return clearentry(dir)
end
do
local _tbl_0 = { }