mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-03-04 02:51:47 +00:00
refactor(lib): update installation lock related comments
This commit is contained in:
parent
aef778883e
commit
1ae6570d8a
1 changed files with 6 additions and 4 deletions
|
@ -187,9 +187,11 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number
|
||||||
local installLockFile = toolDir:join("LOCK")
|
local installLockFile = toolDir:join("LOCK")
|
||||||
local isLocked, lockFileContents = pcall(pathfs.readFile, installLockFile)
|
local isLocked, lockFileContents = pcall(pathfs.readFile, installLockFile)
|
||||||
if isLocked then
|
if isLocked then
|
||||||
-- If the lock was held and we know the same tool that we are trying to install
|
-- If an installation lock was held for the tool we are trying to install, it means
|
||||||
-- is also being installed elsewhere, we wait for that installation attempt to
|
-- that it is also being installed elsewhere. In this case, we wait for that installation
|
||||||
-- finish, i.e., the lock file is removed, and then run the freshly installed tool
|
-- attempt to finish, i.e., when the lock file is removed, and then run the freshly
|
||||||
|
-- installed tool
|
||||||
|
|
||||||
-- Disable the progress bar since we're not actually an installation process
|
-- Disable the progress bar since we're not actually an installation process
|
||||||
_G.interactive = false
|
_G.interactive = false
|
||||||
bar:stop()
|
bar:stop()
|
||||||
|
@ -200,7 +202,7 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number
|
||||||
warn("Waiting for existing installation process for tool to exit")
|
warn("Waiting for existing installation process for tool to exit")
|
||||||
while pathfs.isFile(installLockFile) do
|
while pathfs.isFile(installLockFile) do
|
||||||
if os.time() > lockFile.expiration then
|
if os.time() > lockFile.expiration then
|
||||||
-- If more than 30s has passed since we started waiting for the lock
|
-- If more than 60s has passed since we started waiting for the lock
|
||||||
-- to be released, we assume something went wrong and error; this should
|
-- to be released, we assume something went wrong and error; this should
|
||||||
-- also remove the lock for subsequent runs
|
-- also remove the lock for subsequent runs
|
||||||
error("Installation lock was held for too long (>60s)")
|
error("Installation lock was held for too long (>60s)")
|
||||||
|
|
Loading…
Add table
Reference in a new issue