summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-07-26 22:25:12 +0800
committerruki <[email protected]>2019-07-26 08:31:15 +0800
commitb03883547d69d2173ffc46f2c8b9e4d579247a60 (patch)
treef32ffc69484a9c2ef3da2fd7e7e9278b114217d3
parentc16826e5756f35aecac2323bf7c210fdbf9ba537 (diff)
improve project lock
-rw-r--r--xmake/core/project/project.lua10
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua20
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