3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-22 11:25:31 +00:00

Use 30 as the long distance matching window to support both 32-bit and 64-bit OS

This commit is contained in:
Aiqiao Yan 2020-05-01 14:25:15 -04:00
parent a5d9a3b1a6
commit 75cd46ec0c
5 changed files with 17 additions and 42 deletions

View file

@ -32,10 +32,6 @@ function getWorkingDirectory(): string {
return process.env["GITHUB_WORKSPACE"] ?? process.cwd();
}
function isOS64(): boolean {
return process.platform != "win32" || process.arch === "x64";
}
export async function extractTar(
archivePath: string,
compressionMethod: CompressionMethod
@ -45,12 +41,10 @@ export async function extractTar(
await io.mkdirP(workingDirectory);
// --d: Decompress.
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
// Using 30 here because we also support 32-bit self-hosted runners.
const args = [
...(compressionMethod == CompressionMethod.Zstd
? [
"--use-compress-program",
isOS64() ? "zstd -d --long=31" : "zstd -d --long=30"
]
? ["--use-compress-program", "zstd -d --long=30"]
: ["-z"]),
"-xf",
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
@ -75,13 +69,11 @@ export async function createTar(
);
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
// Using 30 here because we also support 32-bit self-hosted runners.
const workingDirectory = getWorkingDirectory();
const args = [
...(compressionMethod == CompressionMethod.Zstd
? [
"--use-compress-program",
isOS64() ? "zstd -T0 --long=31" : "zstd -T0 --long=30"
]
? ["--use-compress-program", "zstd -T0 --long=30"]
: ["-z"]),
"-cf",
cacheFileName.replace(new RegExp("\\" + path.sep, "g"), "/"),