aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2024-03-22 13:58:26 -0400
committerAdam Harrison <adamdharrison@gmail.com>2024-03-22 13:58:26 -0400
commitf5d74c2591dd7ab013a579c0206881deb2eb2518 (patch)
tree56e84c42a8b28c64e8bc4e8c493981aad885ac7a /src
parentc01125c278275a37d1e95a79af2edc3beb5dd0d3 (diff)
downloadlite-xl-plugin-manager-f5d74c2591dd7ab013a579c0206881deb2eb2518.tar.gz
lite-xl-plugin-manager-f5d74c2591dd7ab013a579c0206881deb2eb2518.zip
Added in ephemeral bottle count, so we only destruct the bottle when the lockfile reads 0.
Diffstat (limited to 'src')
-rw-r--r--src/lpm.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/lpm.lua b/src/lpm.lua
index 645e986..ffa30f8 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -1826,8 +1826,24 @@ function lpm.lite_xl_run(version, ...)
local bottle = Bottle.new(lite_xl, addons, CONFIG)
if not bottle:is_constructed() or REINSTALL then bottle:construct() end
return function()
- bottle:run(common.slice(arguments, i + 1))
- if EPHEMERAL then bottle:destruct() end
+ if EPHEMERAL then
+ local lockfile = bottle.local_path .. PATHSEP .. "lock"
+ if not system.stat(lockfile) then common.write(lockfile, "0") end
+ system.flock(lockfile, function()
+ common.write(lockfile, common.read(lockfile) + 1)
+ end)
+ bottle:run(common.slice(arguments, i + 1))
+ system.flock(lockfile, function()
+ local locks = tonumber(common.read(lockfile))
+ if locks == 1 then
+ bottle:destruct()
+ else
+ common.write(lockfile, locks - 1)
+ end
+ end)
+ else
+ bottle:run(common.slice(arguments, i + 1))
+ end
end
end