Skip to content

Commit

Permalink
fix(windows): download registry archive to file instead of piping data (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
williamboman committed Apr 7, 2023
1 parent 05f663c commit 84af7a1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lua/mason-registry/sources/github.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 84af7a1

Please sign in to comment.