From a64713cef556f994e9db95c2b23e4059917e3219 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 30 Nov 2023 14:58:40 -0500 Subject: Added `fetch_if_not_present` to allow things to function without internet. --- src/lpm.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lpm.lua b/src/lpm.lua index e8eb844..23ad06d 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -664,7 +664,7 @@ function Addon:unstub() if not self:is_stub() or self.inaccessible then return end local repo local status, err = pcall(function() - repo = Repository.url(self.remote):fetch() + repo = Repository.url(self.remote):fetch_if_not_present() local manifest = repo:parse_manifest(self.id) local remote_entry = common.grep(manifest['addons'] or manifest['plugins'], function(e) return e.id == self.id end)[1] if not remote_entry then error("can't find " .. self.type .. " on " .. self.remote) end @@ -1142,6 +1142,11 @@ function Repository:generate_manifest(repo_id) common.write(path .. PATHSEP .. "manifest.json", json.encode({ addons = addons })) end +function Repository:fetch_if_not_present() + if system.stat(self.local_path) then return end + return self:fetch() +end + -- useds to fetch things from a generic place function Repository:fetch() if self:is_local() then return self end -- cgit v1.2.3