Skip to content

Commit

Permalink
_
Browse files Browse the repository at this point in the history
Signed-off-by: Sora Morimoto <sora@morimoto.io>
  • Loading branch information
smorimoto committed Jul 23, 2024
1 parent 31a8a1a commit 64ed6af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
17 changes: 4 additions & 13 deletions packages/cache/__tests__/tar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ test('zstd extract tar', async () => {
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
.concat([
'--use-compress-program',
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
])
.concat(['--use-compress-program', 'zstd -d --long=30'])
.join(' '),
undefined,
{
Expand Down Expand Up @@ -231,10 +228,7 @@ test('zstd create tar', async () => {
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
.concat([
'--use-compress-program',
IS_WINDOWS ? '"zstd -T0 --adapt --long=30"' : 'zstdmt --adapt --long=30'
])
.concat(['--use-compress-program', 'zstd -T0 --adapt --long=30'])
.join(' '),
undefined, // args
{
Expand Down Expand Up @@ -365,10 +359,7 @@ test('zstd list tar', async () => {
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
.concat([
'--use-compress-program',
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
])
.concat(['--use-compress-program', 'zstd -d --long=30'])
.join(' '),
undefined,
{
Expand Down Expand Up @@ -442,7 +433,7 @@ test('zstdWithoutLong list tar', async () => {
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
.concat(['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'])
.concat(['--use-compress-program', 'zstd -d'])
.join(' '),
undefined,
{
Expand Down
23 changes: 5 additions & 18 deletions packages/cache/src/internal/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ async function getDecompressionProgram(
archivePath: string
): Promise<string[]> {
// -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.
// Using 30 here because we also support 32-bit self-hosted runners.
const BSD_TAR_ZSTD =
Expand All @@ -187,26 +186,22 @@ async function getDecompressionProgram(
TarFilename,
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
]
: [
'--use-compress-program',
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
]
: ['--use-compress-program', 'zstd -d --long=30']
case CompressionMethod.ZstdWithoutLong:
return BSD_TAR_ZSTD
? [
'zstd -d --force -o',
TarFilename,
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
]
: ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd']
: ['--use-compress-program', 'zstd -d']
default:
return ['-z']
}
}

// Used for creating the archive
// -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'
// --adapt: Dynamically adapt compression level to I/O conditions.
// --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.
Expand All @@ -228,31 +223,23 @@ async function getCompressionProgram(
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
TarFilename
]
: [
'--use-compress-program',
IS_WINDOWS
? '"zstd -T0 --adapt --long=30"'
: 'zstdmt --adapt --long=30'
]
: ['--use-compress-program', 'zstd -T0 --adapt --long=30']
case CompressionMethod.ZstdWithoutAdapt:
return BSD_TAR_ZSTD
? [
'zstd -T0 --long=30 --force -o',
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
TarFilename
]
: [
'--use-compress-program',
IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
]
: ['--use-compress-program', 'zstd -T0 --long=30']
case CompressionMethod.ZstdWithoutLong:
return BSD_TAR_ZSTD
? [
'zstd -T0 --force -o',
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
TarFilename
]
: ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt']
: ['--use-compress-program', 'zstd -T0']
default:
return ['-z']
}
Expand Down

0 comments on commit 64ed6af

Please sign in to comment.