diff options
| -rw-r--r-- | xmake/core/project/project.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 20 |
2 files changed, 21 insertions, 9 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 581d16e1e..a673513ef 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -296,6 +296,16 @@ function project.directory() return os.projectdir() end +-- get the filelock of the whole project directory +function project.filelock() + local filelock = project._FILELOCK + if filelock == nil then + filelock = io.openlock(path.join(config.directory(), "project.lock")) + project._FILELOCK = filelock + end + return filelock +end + -- get the project info from the given name function project.get(name) return project._INFO and project._INFO:get(name) or nil diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index e6ff9c1de..7fe206019 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -152,13 +152,9 @@ end -- get the filelock of the whole project directory function sandbox_core_project.filelock() - local filelock = sandbox_core_project._FILELOCK - if filelock == nil then - filelock = io.openlock(path.join(config.directory(), "project.lock")) - if not filelock then - raise("cannot create the project lock!") - end - sandbox_core_project._FILELOCK = filelock + local filelock = project.filelock() + if not filelock then + raise("cannot create the project lock!") end return filelock end @@ -170,7 +166,10 @@ function sandbox_core_project.lock(opt) elseif baseoption.get("diagnosis") then utils.warning("the current project is being accessed by other processes, please waiting!") end - return sandbox_core_project.filelock():lock(opt) + local ok, errors = sandbox_core_project.filelock():lock(opt) + if not ok then + raise(errors) + end end -- trylock the whole project @@ -180,7 +179,10 @@ end -- unlock the whole project function sandbox_core_project.unlock() - return sandbox_core_project.filelock():unlock() + local ok, errors = sandbox_core_project.filelock():unlock() + if not ok then + raise(errors) + end end -- get the project mtimes |
