mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-02-07 18:17:24 +00:00
Fall back to extractZip() if extractTar() fails
extractTar() supporst both bsdtar and gnu tar, but only bsdtar supports zip files. While on GH hosted runners bsdtar is used by default that might not be true for other setups, so in case extractTar() fails we fall back to extractZip() and print a message.
This commit is contained in:
parent
1cd7d04150
commit
96bdc9e935
2 changed files with 26 additions and 2 deletions
14
dist/setup/index.js
generated
vendored
14
dist/setup/index.js
generated
vendored
|
|
@ -129171,6 +129171,7 @@ exports.tryGetFromToolCache = tryGetFromToolCache;
|
|||
exports.downloadVersionFromGithub = downloadVersionFromGithub;
|
||||
exports.downloadVersionFromManifest = downloadVersionFromManifest;
|
||||
exports.resolveVersion = resolveVersion;
|
||||
const node_fs_1 = __nccwpck_require__(73024);
|
||||
const path = __importStar(__nccwpck_require__(76760));
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const tc = __importStar(__nccwpck_require__(33472));
|
||||
|
|
@ -129212,7 +129213,18 @@ async function downloadVersion(downloadUrl, artifactName, platform, arch, versio
|
|||
let uvDir;
|
||||
if (platform === "pc-windows-msvc") {
|
||||
// On windows extracting the zip does not create an intermediate directory
|
||||
uvDir = await tc.extractTar(downloadPath, undefined, "x");
|
||||
try {
|
||||
// Try tar first as it's much faster, but only bsdtar supports zip files,
|
||||
// so this my fail if another tar, like gnu tar, ends up being used.
|
||||
uvDir = await tc.extractTar(downloadPath, undefined, "x");
|
||||
}
|
||||
catch (err) {
|
||||
core.info(`Extracting with tar failed, falling back to zip extraction: ${err.message}`);
|
||||
const extension = getExtension(platform);
|
||||
const fullPathWithExtension = `${downloadPath}${extension}`;
|
||||
await node_fs_1.promises.copyFile(downloadPath, fullPathWithExtension);
|
||||
uvDir = await tc.extractZip(fullPathWithExtension);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const extractedDir = await tc.extractTar(downloadPath);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,19 @@ async function downloadVersion(
|
|||
let uvDir: string;
|
||||
if (platform === "pc-windows-msvc") {
|
||||
// On windows extracting the zip does not create an intermediate directory
|
||||
uvDir = await tc.extractTar(downloadPath, undefined, "x");
|
||||
try {
|
||||
// Try tar first as it's much faster, but only bsdtar supports zip files,
|
||||
// so this my fail if another tar, like gnu tar, ends up being used.
|
||||
uvDir = await tc.extractTar(downloadPath, undefined, "x");
|
||||
} catch (err) {
|
||||
core.info(
|
||||
`Extracting with tar failed, falling back to zip extraction: ${(err as Error).message}`,
|
||||
);
|
||||
const extension = getExtension(platform);
|
||||
const fullPathWithExtension = `${downloadPath}${extension}`;
|
||||
await fs.copyFile(downloadPath, fullPathWithExtension);
|
||||
uvDir = await tc.extractZip(fullPathWithExtension);
|
||||
}
|
||||
} else {
|
||||
const extractedDir = await tc.extractTar(downloadPath);
|
||||
uvDir = path.join(extractedDir, artifactName);
|
||||
|
|
|
|||
Loading…
Reference in a new issue