@@ -5,23 +5,33 @@ import * as path from 'path'
5
5
import * as utils from './cacheUtils'
6
6
import { CompressionMethod } from './constants'
7
7
8
- async function getTarPath ( args : string [ ] ) : Promise < string > {
9
- // Explicitly use BSD Tar on Windows
8
+ async function getTarPath (
9
+ args : string [ ] ,
10
+ compressionMethod : CompressionMethod
11
+ ) : Promise < string > {
10
12
const IS_WINDOWS = process . platform === 'win32'
11
13
if ( IS_WINDOWS ) {
12
14
const systemTar = `${ process . env [ 'windir' ] } \\System32\\tar.exe`
13
- if ( existsSync ( systemTar ) ) {
15
+ if ( compressionMethod !== CompressionMethod . Gzip ) {
16
+ // We only use zstandard compression on windows when gnu tar is installed due to
17
+ // a bug with compressing large files with bsdtar + zstd
18
+ args . push ( '--force-local' )
19
+ } else if ( existsSync ( systemTar ) ) {
14
20
return systemTar
15
- } else if ( await utils . useGnuTar ( ) ) {
21
+ } else if ( await utils . isGnuTarInstalled ( ) ) {
16
22
args . push ( '--force-local' )
17
23
}
18
24
}
19
25
return await io . which ( 'tar' , true )
20
26
}
21
27
22
- async function execTar ( args : string [ ] , cwd ?: string ) : Promise < void > {
28
+ async function execTar (
29
+ args : string [ ] ,
30
+ compressionMethod : CompressionMethod ,
31
+ cwd ?: string
32
+ ) : Promise < void > {
23
33
try {
24
- await exec ( `"${ await getTarPath ( args ) } "` , args , { cwd} )
34
+ await exec ( `"${ await getTarPath ( args , compressionMethod ) } "` , args , { cwd} )
25
35
} catch ( error ) {
26
36
throw new Error ( `Tar failed with error: ${ error ?. message } ` )
27
37
}
@@ -59,7 +69,7 @@ export async function extractTar(
59
69
'-C' ,
60
70
workingDirectory . replace ( new RegExp ( `\\${ path . sep } ` , 'g' ) , '/' )
61
71
]
62
- await execTar ( args )
72
+ await execTar ( args , compressionMethod )
63
73
}
64
74
65
75
export async function createTar (
@@ -100,5 +110,5 @@ export async function createTar(
100
110
'--files-from' ,
101
111
manifestFilename
102
112
]
103
- await execTar ( args , archiveFolder )
113
+ await execTar ( args , compressionMethod , archiveFolder )
104
114
}
0 commit comments