aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-05-22 14:55:40 -0400
committerAdam Harrison <adamdharrison@gmail.com>2023-05-22 14:55:40 -0400
commit2137c5bec13fce85ffb3f4bc7726b7a959e16b60 (patch)
tree2209f5963982093b65dc055555a3fa7792a7b779 /src
parent9d2e02a6f7191036b3d6f1db8858ded619693b06 (diff)
downloadlite-xl-plugin-manager-2137c5bec13fce85ffb3f4bc7726b7a959e16b60.tar.gz
lite-xl-plugin-manager-2137c5bec13fce85ffb3f4bc7726b7a959e16b60.zip
Added in warning to let people know when stubs are mismatching versions.
Diffstat (limited to 'src')
-rw-r--r--src/lpm.c2
-rw-r--r--src/lpm.lua15
2 files changed, 12 insertions, 5 deletions
diff --git a/src/lpm.c b/src/lpm.c
index 163c7b0..17da4cc 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -115,7 +115,7 @@ static int lpm_hash(lua_State* L) {
unsigned char chunk[4096];
size_t bytes = fread(chunk, 1, sizeof(chunk), file);
mbedtls_sha256_update_ret(&hash_ctx, chunk, bytes);
- if (bytes < 4096)
+ if (bytes < sizeof(chunk))
break;
}
fclose(file);
diff --git a/src/lpm.lua b/src/lpm.lua
index b3a8642..1f35d1d 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -634,6 +634,8 @@ function Addon:unstub()
if not remote_entry then error("can't find " .. self.type .. " on " .. self.remote) end
local addon = Addon.new(repo, remote_entry)
-- merge in attribtues that are probably more accurate than the stub
+ if addon.version ~= self.version then log_warning(self.id .. " stub on " .. self.repository:url() .. " has differing version from remote (" .. self.version .. " vs " .. addon.version .. "); may lead to install being inconsistent") end
+ -- if addon.mod_version ~= self.mod_version then log_warning(self.id .. " stub on " .. self.repository:url() .. " has differing mod_version from remote (" .. self.mod_version .. " vs " .. addon.mod_version .. ")") end
for k,v in pairs(addon) do self[k] = v end
end)
if not status then self.inaccessible = err end
@@ -646,11 +648,12 @@ function Addon.is_path_different(path1, path2)
local stat1, stat2 = system.stat(path1), system.stat(path2)
if not stat1 or not stat2 or stat1.type ~= stat2.type or stat1.size ~= stat2.size then return true end
if stat1.type == "dir" then
- for i, file in ipairs(system.ls(path1)) do if not common.basename(file):find("^%.") and Addon.is_path_different(path1 .. PATHSEP .. file, path2 .. PATHSEP.. file) then return true end end
+ for i, file in ipairs(system.ls(path1)) do
+ if not common.basename(file):find("^%.") and Addon.is_path_different(path1 .. PATHSEP .. file, path2 .. PATHSEP.. file) then return true end
+ end
return false
- else
- return system.hash(path1, "file") ~= system.hash(path2, "file")
end
+ return system.hash(path1, "file") ~= system.hash(path2, "file")
end
function Addon.is_addon_different(downloaded_path, installed_path)
@@ -917,7 +920,7 @@ end
function Repository.url(url)
if type(url) == "table" then return (url.remote and (url.remote .. ":" .. (url.branch or url.commit)) or url.repo_path) end
- if not url:find("^%a+:") then return Repository.new({ repo_path = url }) end
+ if not url:find("^%a+:") then return Repository.new({ repo_path = url:gsub("[/\\]$", "") }) end
local e = url:reverse():find(":")
local s = e and (#url - e + 1)
local remote, branch_or_commit = url:sub(1, s and (s-1) or #url), s and url:sub(s+1)
@@ -2066,6 +2069,10 @@ not commonly used publically.
if file then print(file) end
os.exit(0)
end
+ if ARGS[2] == "hash" then
+ print(system.hash(ARGS[3], "file"))
+ os.exit(0)
+ end
if ARGS[2] == "extract" then
system.extract(ARGS[3], ARGS[4] or ".")
os.exit(0)