mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 13:29:10 +08:00 
			
		
		
		
	Fix zstd breaking after new version release
This commit is contained in:
		
							
								
								
									
										20
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							@@ -1152,12 +1152,13 @@ function unlinkFile(filePath) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.unlinkFile = unlinkFile;
 | 
			
		||||
function getVersion(app) {
 | 
			
		||||
function getVersion(app, additionalArgs = []) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        core.debug(`Checking ${app} --version`);
 | 
			
		||||
        let versionOutput = '';
 | 
			
		||||
        additionalArgs.push('--version');
 | 
			
		||||
        core.debug(`Checking ${app} ${additionalArgs.join(' ')}`);
 | 
			
		||||
        try {
 | 
			
		||||
            yield exec.exec(`${app} --version`, [], {
 | 
			
		||||
            yield exec.exec(`${app}`, additionalArgs, {
 | 
			
		||||
                ignoreReturnCode: true,
 | 
			
		||||
                silent: true,
 | 
			
		||||
                listeners: {
 | 
			
		||||
@@ -1177,19 +1178,14 @@ function getVersion(app) {
 | 
			
		||||
// Use zstandard if possible to maximize cache performance
 | 
			
		||||
function getCompressionMethod() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const versionOutput = yield getVersion('zstd');
 | 
			
		||||
        const versionOutput = yield getVersion('zstd', ['--quiet']);
 | 
			
		||||
        const version = semver.clean(versionOutput);
 | 
			
		||||
        if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
 | 
			
		||||
            // zstd is not installed
 | 
			
		||||
        core.debug(`zstd version: ${version}`);
 | 
			
		||||
        if (versionOutput === '') {
 | 
			
		||||
            return constants_1.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 constants_1.CompressionMethod.ZstdWithoutLong;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            return constants_1.CompressionMethod.Zstd;
 | 
			
		||||
            return constants_1.CompressionMethod.ZstdWithoutLong;
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user