aboutsummaryrefslogtreecommitdiff
path: root/src/lpm.lua
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2024-03-23 17:05:27 -0400
committerAdam Harrison <adamdharrison@gmail.com>2024-03-23 17:05:27 -0400
commit83a5a4f1f37178df7c937db09b30fc21e1684065 (patch)
tree40a7d86b4b6929c97d4b9ef9561b6a93a44cf961 /src/lpm.lua
parent9fe3c05627014c3568b37d763a7cb4b6d13bfa1c (diff)
downloadlite-xl-plugin-manager-83a5a4f1f37178df7c937db09b30fc21e1684065.tar.gz
lite-xl-plugin-manager-83a5a4f1f37178df7c937db09b30fc21e1684065.zip
Changed how ephemeral bottles work.
Diffstat (limited to 'src/lpm.lua')
-rw-r--r--src/lpm.lua33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/lpm.lua b/src/lpm.lua
index 6496429..448eabe 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -1400,7 +1400,14 @@ function Bottle.new(lite_xl, addons, config, is_system)
if not is_system then
table.sort(self.addons, function(a, b) return (a.id .. ":" .. a.version) < (b.id .. ":" .. b.version) end)
self.hash = system.hash(lite_xl.version .. " " .. common.join(" ", common.map(self.addons, function(p) return (p.repository and p.repository:url() or "") .. ":" .. p.id .. ":" .. p.version end)) .. (config or "") .. (EPHEMERAL and "E" or ""))
- self.local_path = CACHEDIR .. PATHSEP .. "bottles" .. PATHSEP .. self.hash
+ if EPHEMERAL then
+ for i = 1, 1000 do
+ self.local_path = CACHEDIR .. PATHSEP .. "bottles" .. PATHSEP .. self.hash .. "-" .. i
+ if not system.stat(self.local_path) then break elseif i == 1000 then error("can't create epehemeral bottle") end
+ end
+ else
+ self.local_path = CACHEDIR .. PATHSEP .. "bottles" .. PATHSEP .. self.hash
+ end
end
return self
end
@@ -1826,24 +1833,8 @@ 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()
- 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
+ bottle:run(common.slice(arguments, i + 1))
+ if EPHEMERAL then bottle:destruct() end
end
end
@@ -2306,7 +2297,9 @@ Flags have the following effects:
repositories, simply act as if the only repositories
are those specified in this option.
--ephemeral Designates a bottle as 'ephemeral', meaning that it
- is fully cleaned up when lpm exits.
+ is fully cleaned up when lpm exits. Multiple ephemeral
+ bottles will also execute independently of one another
+ even if they share plugins.
--plugin Loads the specified plugin as part of lpm. Used
for customizing lpm for various tasks. Can be
specified as a remote URL. By default, will always