Enable specifying extraction destination

This commit is contained in:
Henry Mercer 2024-11-06 19:47:23 +00:00
parent af49565b85
commit be26fe61b5
6 changed files with 29 additions and 24 deletions

7
lib/tools-download.js generated
View file

@ -63,7 +63,8 @@ async function downloadAndExtract(codeqlURL, authorization, headers, tarVersion,
process.platform === "linux") {
logger.info(`Streaming the extraction of the CodeQL bundle.`);
const toolsInstallStart = perf_hooks_1.performance.now();
const extractedBundlePath = await downloadAndExtractZstdWithStreaming(codeqlURL, authorization, headers, tarVersion, logger);
const extractedBundlePath = await tar.createExtractFolder();
await downloadAndExtractZstdWithStreaming(codeqlURL, extractedBundlePath, authorization, headers, tarVersion, logger);
const combinedDurationMs = Math.round(perf_hooks_1.performance.now() - toolsInstallStart);
logger.info(`Finished downloading and extracting CodeQL bundle to ${extractedBundlePath} (${(0, logging_1.formatDuration)(combinedDurationMs)}).`);
return {
@ -101,7 +102,7 @@ async function downloadAndExtract(codeqlURL, authorization, headers, tarVersion,
},
};
}
async function downloadAndExtractZstdWithStreaming(codeqlURL, authorization, headers, tarVersion, logger) {
async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorization, headers, tarVersion, logger) {
headers = Object.assign({ "User-Agent": "CodeQL Action" }, authorization ? { authorization } : {}, headers);
const response = await new Promise((resolve) => follow_redirects_1.https.get(codeqlURL, {
headers,
@ -110,7 +111,7 @@ async function downloadAndExtractZstdWithStreaming(codeqlURL, authorization, hea
if (response.statusCode !== 200) {
throw new Error(`Failed to download CodeQL bundle from ${codeqlURL}. HTTP status code: ${response.statusCode}.`);
}
return await tar.extractTarZst(response, tarVersion, logger);
await tar.extractTarZst(response, dest, tarVersion, logger);
}
function sanitizeUrlForStatusReport(url) {
return ["github/codeql-action", "dsp-testing/codeql-cli-nightlies"].some((repo) => url.startsWith(`https://github.com/${repo}/releases/download/`))