mirror of https://github.com/actions/toolkit
React to feedback
parent
9a3466a094
commit
fde6221228
|
@ -86,14 +86,20 @@ export async function getCompressionMethod(): Promise<CompressionMethod> {
|
||||||
if (process.platform === 'win32' && !isGnuTarInstalled()) {
|
if (process.platform === 'win32' && !isGnuTarInstalled()) {
|
||||||
// Disable zstd due to bug https://github.com/actions/cache/issues/301
|
// Disable zstd due to bug https://github.com/actions/cache/issues/301
|
||||||
return CompressionMethod.Gzip
|
return CompressionMethod.Gzip
|
||||||
|
}
|
||||||
|
|
||||||
|
const versionOutput = await getVersion('zstd')
|
||||||
|
const version = semver.clean(versionOutput)
|
||||||
|
|
||||||
|
if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
|
||||||
|
// zstd is not installed
|
||||||
|
return CompressionMethod.Gzip
|
||||||
|
} else if (!version || semver.lt(version, 'v1.3.2')) {
|
||||||
|
// zstd is installed but using a version earlier than v1.3.2
|
||||||
|
// v1.3.2 is required to use the `--long` options in zstd
|
||||||
|
return CompressionMethod.ZstdWithoutLong
|
||||||
} else {
|
} else {
|
||||||
const versionOutput = await getVersion('zstd')
|
return CompressionMethod.Zstd
|
||||||
const version = semver.clean(versionOutput)
|
|
||||||
return !versionOutput.toLowerCase().includes('zstd command line interface')
|
|
||||||
? CompressionMethod.Gzip
|
|
||||||
: !version || semver.lt(version, 'v1.3.2')
|
|
||||||
? CompressionMethod.ZstdOld
|
|
||||||
: CompressionMethod.Zstd
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@ export enum CacheFilename {
|
||||||
|
|
||||||
export enum CompressionMethod {
|
export enum CompressionMethod {
|
||||||
Gzip = 'gzip',
|
Gzip = 'gzip',
|
||||||
ZstdOld = 'zstd-old',
|
// Long range mode was added to zstd in v1.3.2.
|
||||||
|
// This enum is for earlier version of zstd that does not have --long support
|
||||||
|
ZstdWithoutLong = 'zstd-without-long',
|
||||||
Zstd = 'zstd'
|
Zstd = 'zstd'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,18 +51,18 @@ export async function extractTar(
|
||||||
// --d: Decompress.
|
// --d: Decompress.
|
||||||
// --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 getProg(): string[] {
|
function getCompressionProgram(): string[] {
|
||||||
switch (compressionMethod) {
|
switch (compressionMethod) {
|
||||||
case CompressionMethod.Zstd:
|
case CompressionMethod.Zstd:
|
||||||
return ['--use-compress-program', 'zstd -d --long=30']
|
return ['--use-compress-program', 'zstd -d --long=30']
|
||||||
case CompressionMethod.ZstdOld:
|
case CompressionMethod.ZstdWithoutLong:
|
||||||
return ['--use-compress-program', 'zstd -d']
|
return ['--use-compress-program', 'zstd -d']
|
||||||
default:
|
default:
|
||||||
return ['-z']
|
return ['-z']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const args = [
|
const args = [
|
||||||
...getProg(),
|
...getCompressionProgram(),
|
||||||
'-xf',
|
'-xf',
|
||||||
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'-P',
|
'-P',
|
||||||
|
@ -90,18 +90,18 @@ export async function createTar(
|
||||||
// --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 getProg(): string[] {
|
function getCompressionProgram(): string[] {
|
||||||
switch (compressionMethod) {
|
switch (compressionMethod) {
|
||||||
case CompressionMethod.Zstd:
|
case CompressionMethod.Zstd:
|
||||||
return ['--use-compress-program', 'zstd -T0 --long=30']
|
return ['--use-compress-program', 'zstd -T0 --long=30']
|
||||||
case CompressionMethod.ZstdOld:
|
case CompressionMethod.ZstdWithoutLong:
|
||||||
return ['--use-compress-program', 'zstd -T0']
|
return ['--use-compress-program', 'zstd -T0']
|
||||||
default:
|
default:
|
||||||
return ['-z']
|
return ['-z']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const args = [
|
const args = [
|
||||||
...getProg(),
|
...getCompressionProgram(),
|
||||||
'-cf',
|
'-cf',
|
||||||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'-P',
|
'-P',
|
||||||
|
|
Loading…
Reference in New Issue