From 84af7a1fa1dbdb0f201849be7993d999a05d973b Mon Sep 17 00:00:00 2001 From: William Boman Date: Fri, 7 Apr 2023 22:33:43 +0200 Subject: fix(windows): download registry archive to file instead of piping data (#1189) Accessing binary data from the stdout of pwsh.exe's iwr seems to be causing data corruption leading to inability to unpack the archive. --- lua/mason-registry/sources/github.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lua') diff --git a/lua/mason-registry/sources/github.lua b/lua/mason-registry/sources/github.lua index f4fd837a..ec758144 100644 --- a/lua/mason-registry/sources/github.lua +++ b/lua/mason-registry/sources/github.lua @@ -134,15 +134,17 @@ function GitHubRegistrySource:install() log.trace("Resolved latest registry version", self, version) end - local zip_buffer = try( - fetch(settings.current.github.download_url_template:format(self.spec.repo, version, "registry.json.zip")):map_err( - _.always "Failed to download registry archive." - ) - ) + local zip_file = path.concat { self.root_dir, "registry.json.zip" } + try(fetch(settings.current.github.download_url_template:format(self.spec.repo, version, "registry.json.zip"), { + out_file = zip_file, + }):map_err(_.always "Failed to download registry archive.")) + local zip_buffer = fs.async.read_file(zip_file) local registry_contents = try( Result.pcall(zzlib.unzip, zip_buffer, "registry.json") + :on_failure(_.partial(log.error, "Failed to unpack registry archive.")) :map_err(_.always "Failed to unpack registry archive.") ) + pcall(fs.async.unlink, zip_file) local checksums = try( fetch(settings.current.github.download_url_template:format(self.spec.repo, version, "checksums.txt")):map_err( -- cgit v1.2.3-70-g09d2