mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-03 18:53:18 +08:00
React to feedback
This commit is contained in:
@@ -242,7 +242,7 @@ export async function downloadCache(
|
||||
|
||||
if (contentLengthHeader) {
|
||||
const expectedLength = parseInt(contentLengthHeader)
|
||||
const actualLength = utils.getArchiveFileSize(archivePath)
|
||||
const actualLength = utils.getArchiveFileSizeIsBytes(archivePath)
|
||||
|
||||
if (actualLength !== expectedLength) {
|
||||
throw new Error(
|
||||
@@ -399,7 +399,7 @@ export async function saveCache(
|
||||
|
||||
// Commit Cache
|
||||
core.debug('Commiting cache')
|
||||
const cacheSize = utils.getArchiveFileSize(archivePath)
|
||||
const cacheSize = utils.getArchiveFileSizeIsBytes(archivePath)
|
||||
const commitCacheResponse = await commitCache(httpClient, cacheId, cacheSize)
|
||||
if (!isSuccessStatusCode(commitCacheResponse.statusCode)) {
|
||||
throw new Error(
|
||||
|
||||
3
packages/cache/src/internal/cacheUtils.ts
vendored
3
packages/cache/src/internal/cacheUtils.ts
vendored
@@ -34,7 +34,7 @@ export async function createTempDirectory(): Promise<string> {
|
||||
return dest
|
||||
}
|
||||
|
||||
export function getArchiveFileSize(filePath: string): number {
|
||||
export function getArchiveFileSizeIsBytes(filePath: string): number {
|
||||
return fs.statSync(filePath).size
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ async function getVersion(app: string): Promise<string> {
|
||||
return versionOutput
|
||||
}
|
||||
|
||||
// Use zstandard if possible to maximize cache performance
|
||||
export async function getCompressionMethod(): Promise<CompressionMethod> {
|
||||
const versionOutput = await getVersion('zstd')
|
||||
return versionOutput.toLowerCase().includes('zstd command line interface')
|
||||
|
||||
Reference in New Issue
Block a user