Only try zstd for specified version ranges of tar

This commit is contained in:
Henry Mercer 2024-08-16 12:13:03 +01:00
parent cf64c3e3a3
commit ffa1b05b27
6 changed files with 201 additions and 48 deletions

19
lib/setup-codeql.js generated
View file

@ -48,6 +48,7 @@ const api = __importStar(require("./api-client"));
// creation scripts. Ensure that any changes to the format of this file are compatible with both of
// these dependents.
const defaults = __importStar(require("./defaults.json"));
const tar = __importStar(require("./tar"));
const util = __importStar(require("./util"));
const util_1 = require("./util");
var ToolsSource;
@ -397,7 +398,7 @@ const downloadCodeQL = async function (codeqlURL, maybeBundleVersion, maybeCliVe
logger.debug(`Finished downloading CodeQL bundle to ${archivedBundlePath} (${downloadDurationMs} ms).`);
logger.debug("Extracting CodeQL bundle.");
const extractionStart = perf_hooks_1.performance.now();
const { extractedBundlePath, compressionMethod } = await extractBundle(archivedBundlePath);
const { compressionMethod, outputPath: extractedBundlePath } = await tar.extract(archivedBundlePath);
const extractionDurationMs = Math.round(perf_hooks_1.performance.now() - extractionStart);
logger.debug(`Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionDurationMs} ms).`);
await cleanUpGlob(archivedBundlePath, "CodeQL bundle archive", logger);
@ -514,20 +515,4 @@ async function cleanUpGlob(glob, name, logger) {
logger.warning(`Failed to clean up ${name}: ${e}.`);
}
}
async function extractBundle(archivedBundlePath) {
if (archivedBundlePath.endsWith(".tar.gz")) {
return {
compressionMethod: "gzip",
// While we could also ask tar to autodetect the compression method,
// we defensively keep the gzip call identical as requesting a gzipped
// bundle will soon be a fallback option.
extractedBundlePath: await toolcache.extractTar(archivedBundlePath),
};
}
return {
compressionMethod: "zstd",
// tar will autodetect the compression method
extractedBundlePath: await toolcache.extractTar(archivedBundlePath, undefined, "x"),
};
}
//# sourceMappingURL=setup-codeql.js.map