Infer compression method from URL
Using the downloaded path is unreliable since we may have removed the file extension.
This commit is contained in:
parent
379271d235
commit
27dbb1ab21
6 changed files with 48 additions and 36 deletions
27
lib/tar.js
generated
27
lib/tar.js
generated
|
|
@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isZstdAvailable = isZstdAvailable;
|
||||
exports.extract = extract;
|
||||
exports.inferCompressionMethod = inferCompressionMethod;
|
||||
const toolrunner_1 = require("@actions/exec/lib/toolrunner");
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const safe_which_1 = require("@chrisgavin/safe-which");
|
||||
|
|
@ -89,21 +90,23 @@ async function isZstdAvailable(logger) {
|
|||
return { available: false };
|
||||
}
|
||||
}
|
||||
async function extract(path) {
|
||||
if (path.endsWith(".tar.gz")) {
|
||||
return {
|
||||
compressionMethod: "gzip",
|
||||
async function extract(path, compressionMethod) {
|
||||
switch (compressionMethod) {
|
||||
case "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.
|
||||
outputPath: await toolcache.extractTar(path),
|
||||
};
|
||||
return await toolcache.extractTar(path);
|
||||
case "zstd":
|
||||
// By specifying only the "x" flag, we ask tar to autodetect the
|
||||
// compression method.
|
||||
return await toolcache.extractTar(path, undefined, "x");
|
||||
}
|
||||
return {
|
||||
compressionMethod: "zstd",
|
||||
// By specifying only the "x" flag, we ask tar to autodetect the compression
|
||||
// method.
|
||||
outputPath: await toolcache.extractTar(path, undefined, "x"),
|
||||
};
|
||||
}
|
||||
function inferCompressionMethod(path) {
|
||||
if (path.endsWith(".tar.gz")) {
|
||||
return "gzip";
|
||||
}
|
||||
return "zstd";
|
||||
}
|
||||
//# sourceMappingURL=tar.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue