1
0
Fork 0

Use zstd short flag version for win runners. Update comments to reflect the same. Fix --d to -d in comments.

pull/1152/head
Lovepreet Singh 2022-08-13 18:01:07 +00:00
parent 63c66cf07e
commit 8bd9e29d3c
1 changed files with 11 additions and 2 deletions

View File

@ -61,14 +61,17 @@ export async function extractTar(
// Create directory to extract tar into // Create directory to extract tar into
const workingDirectory = getWorkingDirectory() const workingDirectory = getWorkingDirectory()
await io.mkdirP(workingDirectory) await io.mkdirP(workingDirectory)
// --d: Decompress. // -d: Decompress.
// unzstd is equivalent to 'zstd -d'
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. // --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. // Using 30 here because we also support 32-bit self-hosted runners.
function getCompressionProgram(): string[] { function getCompressionProgram(): string[] {
switch (compressionMethod) { switch (compressionMethod) {
case CompressionMethod.Zstd: case CompressionMethod.Zstd:
if (process.platform === 'win32') return ['--use-compress-program=zstd -d --long=30']
return ['--use-compress-program', 'unzstd --long=30'] return ['--use-compress-program', 'unzstd --long=30']
case CompressionMethod.ZstdWithoutLong: case CompressionMethod.ZstdWithoutLong:
if (process.platform === 'win32') return ['--use-compress-program=zstd -d']
return ['--use-compress-program', 'unzstd'] return ['--use-compress-program', 'unzstd']
default: default:
return ['-z'] return ['-z']
@ -100,14 +103,17 @@ export async function createTar(
const workingDirectory = getWorkingDirectory() const workingDirectory = getWorkingDirectory()
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores. // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
// zstdmt is equivalent to 'zstd -T0'
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. // --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. // Using 30 here because we also support 32-bit self-hosted runners.
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd. // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
function getCompressionProgram(): string[] { function getCompressionProgram(): string[] {
switch (compressionMethod) { switch (compressionMethod) {
case CompressionMethod.Zstd: case CompressionMethod.Zstd:
if (process.platform === 'win32') return ['--use-compress-program=zstd -T0 --long=30']
return ['--use-compress-program', 'zstdmt --long=30'] return ['--use-compress-program', 'zstdmt --long=30']
case CompressionMethod.ZstdWithoutLong: case CompressionMethod.ZstdWithoutLong:
if (process.platform === 'win32') return ['--use-compress-program=zstd -T0']
return ['--use-compress-program', 'zstdmt'] return ['--use-compress-program', 'zstdmt']
default: default:
return ['-z'] return ['-z']
@ -133,15 +139,18 @@ export async function listTar(
archivePath: string, archivePath: string,
compressionMethod: CompressionMethod compressionMethod: CompressionMethod
): Promise<void> { ): Promise<void> {
// --d: Decompress. // -d: Decompress.
// unzstd is equivalent to 'zstd -d'
// --long=#: Enables long distance matching with # bits. // --long=#: Enables long distance matching with # bits.
// Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. // 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. // Using 30 here because we also support 32-bit self-hosted runners.
function getCompressionProgram(): string[] { function getCompressionProgram(): string[] {
switch (compressionMethod) { switch (compressionMethod) {
case CompressionMethod.Zstd: case CompressionMethod.Zstd:
if (process.platform === 'win32') return ['--use-compress-program=zstd -d --long=30']
return ['--use-compress-program', 'unzstd --long=30'] return ['--use-compress-program', 'unzstd --long=30']
case CompressionMethod.ZstdWithoutLong: case CompressionMethod.ZstdWithoutLong:
if (process.platform === 'win32') return ['--use-compress-program=zstd -d']
return ['--use-compress-program', 'unzstd'] return ['--use-compress-program', 'unzstd']
default: default:
return ['-z'] return ['-z']