This commit is contained in:
Shubham Tiwari
2022-06-20 04:54:54 +00:00
committed by GitHub
parent 639c79e4a4
commit 8c47ec23fe
3 changed files with 41 additions and 29 deletions
+14 -14
View File
@@ -4,7 +4,7 @@ import * as utils from './internal/cacheUtils'
import * as cacheHttpClient from './internal/cacheHttpClient'
import {createTar, extractTar, listTar} from './internal/tar'
import {DownloadOptions, UploadOptions} from './options'
import { ArtifactCacheEntry } from './internal/contracts'
import {ArtifactCacheEntry} from './internal/contracts'
export class ValidationError extends Error {
constructor(message: string) {
@@ -87,10 +87,10 @@ export async function restoreCache(
}
const compressionMethod = await utils.getCompressionMethod()
let archivePath = ""
let archivePath = ''
try {
// path are needed to compute version
const cacheEntry = await cacheHttpClient.getCacheEntry(keys, paths, {
// path are needed to compute version
const cacheEntry = await cacheHttpClient.getCacheEntry(keys, paths, {
compressionMethod
})
@@ -98,13 +98,13 @@ export async function restoreCache(
// Cache not found
return undefined
}
archivePath = path.join(
archivePath = path.join(
await utils.createTempDirectory(),
utils.getCacheFileName(compressionMethod)
)
core.debug(`Archive Path: ${archivePath}`)
// Download the cache from the cache entry
await cacheHttpClient.downloadCache(
cacheEntry.archiveLocation,
@@ -125,12 +125,12 @@ export async function restoreCache(
await extractTar(archivePath, compressionMethod)
core.info('Cache restored successfully')
return cacheEntry.cacheKey
} catch(error) {
// Supress all cache related errors because caching should be optional
core.warning(`Fail to restore: ${error}`);
}finally {
} catch (error) {
// Supress all cache related errors because caching should be optional
core.warning(`Fail to restore: ${error}`)
} finally {
// Try to delete the archive to save space
try {
await utils.unlinkFile(archivePath)
@@ -224,8 +224,8 @@ export async function saveCache(
core.debug(`Saving Cache (ID: ${cacheId})`)
await cacheHttpClient.saveCache(cacheId, archivePath, options)
} catch(error) {
const typedError = error as Error;
} catch (error) {
const typedError = error as Error
if (typedError.name === ReserveCacheError.name) {
core.info(`Fail to save: ${typedError.message}`)
} else {