aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2024-07-23 13:29:22 -0400
committerAdam Harrison <adamdharrison@gmail.com>2024-07-23 13:29:22 -0400
commitf886d77abc5be9eddf4fd0ea8c78754dfd46d819 (patch)
treea0b9d396eda40ccd5b16ac5fd07d972c1159abd1 /src
parenta971de35d3df0f08ee195ab87828788f865e4f67 (diff)
downloadlite-xl-plugin-manager-f886d77abc5be9eddf4fd0ea8c78754dfd46d819.tar.gz
lite-xl-plugin-manager-f886d77abc5be9eddf4fd0ea8c78754dfd46d819.zip
Should be more robust at detecthing orphans.
Diffstat (limited to 'src')
-rw-r--r--src/lpm.lua19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/lpm.lua b/src/lpm.lua
index c75d4cd..783d4d6 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -1014,20 +1014,20 @@ function Addon:is_explicitly_installed(bottle)
end
-function Addon:get_orphaned_dependencies(bottle)
+function Addon:get_orphaned_dependencies(bottle, uninstalling)
local t = {}
+ uninstalling = uninstalling or { [self.id] = true }
local installed_addons = system_bottle:installed_addons()
- for id, options in pairs(self.dependencies) do
- local dependency = bottle:get_addon(id, options.version)
+ for i, id in ipairs(common.canonical_order(self.dependencies)) do
+ local options = self.dependencies[id]
+ local dependency = common.grep({ bottle:get_addon(id, options.version) }, function(e) return e.type == "meta" or e:is_installed(bottle) end)[1]
if dependency then
- if ( dependency.type == "meta" or dependency:is_installed(bottle) )
- and #common.grep(installed_addons, function(addon) return addon ~= self and addon:depends_on(dependency) end) == 0
+ if #common.grep(installed_addons, function(addon) return addon ~= self and addon:depends_on(dependency) and not uninstalling[addon.id] end) == 0
and not ( dependency:is_explicitly_installed(bottle) or dependency:is_core(bottle) )
then
table.insert(t, dependency)
- if dependency.type == "meta" then
- t = common.concat(t, dependency:get_orphaned_dependencies(bottle))
- end
+ uninstalling[dependency.id] = true
+ t = common.concat(t, dependency:get_orphaned_dependencies(bottle, uninstalling))
end
end
end
@@ -1611,7 +1611,8 @@ function Bottle:all_addons()
mod_version = self.lite_xl.mod_version,
path = addon_type .. PATHSEP .. v,
description = (hash[id] and hash[id][1].description or nil),
- repo_path = (hash[id] and hash[id][1].local_path or nil)
+ repo_path = (hash[id] and hash[id][1].local_path or nil),
+ dependencies = (hash[id] and hash[id][1].dependencies or nil)
}))
if not hash[id] then hash[id] = t[#t] end
end