mirror of https://github.com/actions/toolkit
Add better comments
parent
d7ae8cd1ef
commit
cad074ceef
|
@ -96,8 +96,7 @@ export async function restoreCache(
|
|||
compressionMethod
|
||||
})
|
||||
if (!cacheEntry?.archiveLocation) {
|
||||
// This is to support the old cache entry created
|
||||
// by the old version of the cache action on windows.
|
||||
// This is to support the old cache entry created by gzip on windows.
|
||||
if (
|
||||
process.platform === 'win32' &&
|
||||
compressionMethod !== CompressionMethod.Gzip
|
||||
|
@ -111,7 +110,7 @@ export async function restoreCache(
|
|||
}
|
||||
|
||||
core.debug(
|
||||
"Couldn't find cache entry with zstd compression, falling back to gzip compression"
|
||||
"Couldn't find cache entry with zstd compression, falling back to gzip compression."
|
||||
)
|
||||
} else {
|
||||
// Cache not found
|
||||
|
|
|
@ -104,6 +104,7 @@ export async function getCacheEntry(
|
|||
httpClient.getJson<ArtifactCacheEntry>(getCacheApiUrl(resource))
|
||||
)
|
||||
if (response.statusCode === 204) {
|
||||
// Cache not found
|
||||
return null
|
||||
}
|
||||
if (!isSuccessStatusCode(response.statusCode)) {
|
||||
|
@ -113,6 +114,7 @@ export async function getCacheEntry(
|
|||
const cacheResult = response.result
|
||||
const cacheDownloadUrl = cacheResult?.archiveLocation
|
||||
if (!cacheDownloadUrl) {
|
||||
// Cache achiveLocation not found
|
||||
throw new Error('Cache not found.')
|
||||
}
|
||||
core.setSecret(cacheDownloadUrl)
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
// Function also mutates the args array. For non-mutation call with passing an empty array.
|
||||
// Returns tar path and type: BSD or GNU
|
||||
async function getTarPath(): Promise<ArchiveTool> {
|
||||
switch (process.platform) {
|
||||
case 'win32': {
|
||||
|
@ -43,6 +43,7 @@ async function getTarPath(): Promise<ArchiveTool> {
|
|||
default:
|
||||
break
|
||||
}
|
||||
// Default assumption is GNU tar is present in path
|
||||
return <ArchiveTool>{
|
||||
path: await io.which('tar', true),
|
||||
type: ArchiveToolType.GNU
|
||||
|
@ -60,6 +61,7 @@ async function getTarArgs(
|
|||
const cacheFileName = utils.getCacheFileName(compressionMethod)
|
||||
const tarFile = 'cache.tar'
|
||||
const workingDirectory = getWorkingDirectory()
|
||||
// Speficic args for BSD tar on windows for workaround
|
||||
const BSD_TAR_ZSTD =
|
||||
tarPath.type === ArchiveToolType.BSD &&
|
||||
compressionMethod !== CompressionMethod.Gzip &&
|
||||
|
@ -122,6 +124,7 @@ async function getTarArgs(
|
|||
return args
|
||||
}
|
||||
|
||||
// Returns commands to run tar and compression program
|
||||
async function getCommands(
|
||||
compressionMethod: CompressionMethod,
|
||||
type: string,
|
||||
|
@ -201,6 +204,7 @@ async function getDecompressionProgram(
|
|||
}
|
||||
}
|
||||
|
||||
// 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'
|
||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||
|
@ -240,6 +244,7 @@ async function getCompressionProgram(
|
|||
}
|
||||
}
|
||||
|
||||
// Executes all commands as separate processes
|
||||
async function execCommands(commands: string[], cwd?: string): Promise<void> {
|
||||
for (const command of commands) {
|
||||
try {
|
||||
|
@ -252,6 +257,7 @@ async function execCommands(commands: string[], cwd?: string): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
// List the contents of a tar
|
||||
export async function listTar(
|
||||
archivePath: string,
|
||||
compressionMethod: CompressionMethod
|
||||
|
@ -260,6 +266,7 @@ export async function listTar(
|
|||
await execCommands(commands)
|
||||
}
|
||||
|
||||
// Extract a tar
|
||||
export async function extractTar(
|
||||
archivePath: string,
|
||||
compressionMethod: CompressionMethod
|
||||
|
@ -271,6 +278,7 @@ export async function extractTar(
|
|||
await execCommands(commands)
|
||||
}
|
||||
|
||||
// Create a tar
|
||||
export async function createTar(
|
||||
archiveFolder: string,
|
||||
sourceDirectories: string[],
|
||||
|
|
Loading…
Reference in New Issue