aboutsummaryrefslogtreecommitdiff
path: root/src/lpm.lua
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-02-19 23:20:44 -0500
committerAdam Harrison <adamdharrison@gmail.com>2023-02-19 23:20:44 -0500
commitd17e85ebdb4b1f9204505c1bed1b8dae3b80f2af (patch)
tree4530c9f72311b3c360982f9d0fc317d2487cebb6 /src/lpm.lua
parent0b6bcfa29fa55e2a69fd9b01e8633abf808344ef (diff)
downloadlite-xl-plugin-manager-d17e85ebdb4b1f9204505c1bed1b8dae3b80f2af.tar.gz
lite-xl-plugin-manager-d17e85ebdb4b1f9204505c1bed1b8dae3b80f2af.zip
Added in purge, and added in additional paths.
Diffstat (limited to 'src/lpm.lua')
-rw-r--r--src/lpm.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lpm.lua b/src/lpm.lua
index 7af1f0f..0261065 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -408,10 +408,17 @@ function common.mkdirp(path)
local stat = system.stat(path)
if stat and stat.type == "dir" then return true end
if stat and stat.type == "file" then error("path " .. path .. " exists") end
+ local segments = { common.split("[/\\]", path) }
local target
- for _, dirname in ipairs({ common.split("[/\\]", path) }) do
+ local extant_root = 0
+ for i, dirname in ipairs(segments) do -- we need to do this, incase directories earlier in the chain exist, but we don't have permission to read.
target = target and target .. PATHSEP .. dirname or dirname
- if target ~= "" and not target:find("^[A-Z]:$") and not system.stat(target) then system.mkdir(target) end
+ if system.stat(target) then extant_root = i end
+ end
+ target = nil
+ for i, dirname in ipairs(segments) do
+ target = target and target .. PATHSEP .. dirname or dirname
+ if i >= extant_root and target ~= "" and not target:find("^[A-Z]:$") and not system.stat(target) then system.mkdir(target) end
end
end
function common.copy(src, dst, hidden)
@@ -1014,7 +1021,8 @@ function Repository:fetch()
if not status then
if path then
common.rmrf(path)
- if #system.ls(common.dirname(path)) == 0 then common.rmrf(common.dirname(path)) end
+ local dir = common.dirname(path)
+ if system.stat(dir) and #system.ls(dir) == 0 then common.rmrf(dir) end
end
error(err)
end