Skip to content

Commit 29cd235

Browse files
authored
Use tar for extracting the uv zip file on Windows too (#660)
Use extractTar() instead of extractZip() which is very slow for some reason (0.3s vs 10s) Fixes #659
1 parent 2ddd2b9 commit 29cd235

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

dist/setup/index.js

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/download/download-version.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,21 @@ async function downloadVersion(
108108
await validateChecksum(checkSum, downloadPath, arch, platform, version);
109109

110110
let uvDir: string;
111-
const extension = getExtension(platform);
112111
if (platform === "pc-windows-msvc") {
113-
const fullPathWithExtension = `${downloadPath}${extension}`;
114-
await fs.copyFile(downloadPath, fullPathWithExtension);
115-
uvDir = await tc.extractZip(fullPathWithExtension);
116112
// On windows extracting the zip does not create an intermediate directory
113+
try {
114+
// Try tar first as it's much faster, but only bsdtar supports zip files,
115+
// so this my fail if another tar, like gnu tar, ends up being used.
116+
uvDir = await tc.extractTar(downloadPath, undefined, "x");
117+
} catch (err) {
118+
core.info(
119+
`Extracting with tar failed, falling back to zip extraction: ${(err as Error).message}`,
120+
);
121+
const extension = getExtension(platform);
122+
const fullPathWithExtension = `${downloadPath}${extension}`;
123+
await fs.copyFile(downloadPath, fullPathWithExtension);
124+
uvDir = await tc.extractZip(fullPathWithExtension);
125+
}
117126
} else {
118127
const extractedDir = await tc.extractTar(downloadPath);
119128
uvDir = path.join(extractedDir, artifactName);

0 commit comments

Comments
 (0)