diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2023-05-22 15:34:07 -0400 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2023-05-22 15:34:07 -0400 |
commit | 3faf74e5d881fdc63a8c204801c0db2792e8f7db (patch) | |
tree | 14f145b84d0bed2a67a53caf3b8b3fc35d6e1706 | |
parent | ea699db36145ac11ef147b611c9abf67436f3ec7 (diff) | |
download | lite-xl-plugin-manager-3faf74e5d881fdc63a8c204801c0db2792e8f7db.tar.gz lite-xl-plugin-manager-3faf74e5d881fdc63a8c204801c0db2792e8f7db.zip |
Better error handling for invalid manifests.
-rw-r--r-- | src/lpm.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lpm.lua b/src/lpm.lua index 6d5b1a2..5ea568e 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -460,6 +460,11 @@ function common.chdir(dir, callback) system.chdir(wd) if not status then error(err) end end +function common.stat(path) + local stat = system.stat(path) + if not stat then error("can't find file or directory at " .. path) end + return stat +end local LATEST_MOD_VERSION = "3.0.0" local EXECUTABLE_EXTENSION = PLATFORM == "windows" and ".exe" or "" @@ -768,16 +773,16 @@ function Addon:install(bottle, installing) log_action("Installing " .. self.organization .. " " .. self.type .. " located at " .. (self.local_path or self.remote) .. " to " .. install_path) end - if self.organization == "complex" and self.path and system.stat(self.local_path).type ~= "dir" then common.mkdirp(install_path) end + if self.organization == "complex" and self.path and common.stat(self.local_path).type ~= "dir" then common.mkdirp(install_path) end if self.url then -- remote simple plugin local path = temporary_install_path .. (self.organization == 'complex' and self.path and system.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") common.get(self.url, path, self.checksum, write_progress_bar) log_action("Downloaded file " .. self.url .. " to " .. path) if system.hash(path, "file") ~= self.checksum then fatal_warning("checksum doesn't match for " .. path) end elseif self.path then -- local plugin that has a local path - local path = install_path .. (self.organization == 'complex' and self.path and system.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") + local path = install_path .. (self.organization == 'complex' and self.path and common.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") local temporary_path = temporary_install_path .. (self.organization == 'complex' and self.path and system.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") - if self.organization == 'complex' and self.path and system.stat(self.local_path).type ~= "dir" then common.mkdirp(temporary_install_path) end + if self.organization == 'complex' and self.path and common.stat(self.local_path).type ~= "dir" then common.mkdirp(temporary_install_path) end if SYMLINK then log_action("Symlinking " .. self.local_path .. " to " .. path) system.symlink(self.local_path, temporary_path) @@ -786,7 +791,7 @@ function Addon:install(bottle, installing) common.copy(self.local_path, temporary_path) end elseif self.organization == 'complex' then -- complex plugin without local path - local path = install_path .. (self.organization == 'complex' and self.path and system.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") + local path = install_path .. (self.organization == 'complex' and self.path and common.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") if SYMLINK then log_action("Symlinking " .. self.local_path .. " to " .. path) system.symlink(self.local_path, temporary_install_path) |