This commit is contained in:
Deepak Dahiya
2022-03-31 10:41:54 +00:00
committed by GitHub
parent bda035c74d
commit daa24d7958
4 changed files with 51 additions and 25 deletions
+17 -8
View File
@@ -177,21 +177,30 @@ export async function saveCache(
const cacheSize = archiveFileSize
core.debug('Reserving Cache')
let reserveCacheResponse = await cacheHttpClient.reserveCache(key, paths, {
compressionMethod,
cacheSize
})
const reserveCacheResponse = await cacheHttpClient.reserveCache(
key,
paths,
{
compressionMethod,
cacheSize
}
)
if(reserveCacheResponse?.statusCode === 400 && reserveCacheResponse?.typeKey === "InvalidReserveCacheRequestException"){
if (
reserveCacheResponse?.statusCode === 400 &&
reserveCacheResponse?.typeKey === 'InvalidReserveCacheRequestException'
) {
throw new ReserveCacheError(
reserveCacheResponse?.message ??
`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
`Cache size of ~${Math.round(
archiveFileSize / (1024 * 1024)
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
)
}
if(reserveCacheResponse?.result?.cacheId){
if (reserveCacheResponse?.result?.cacheId) {
cacheId = reserveCacheResponse?.result?.cacheId
}else{
} else {
throw new ReserveCacheError(
`Unable to reserve cache with key ${key}, another job may be creating this cache.`
)
+1 -3
View File
@@ -1,7 +1,5 @@
import {CompressionMethod} from './constants'
import {
ITypedResponse
} from '@actions/http-client/interfaces'
import {ITypedResponse} from '@actions/http-client/interfaces'
export interface ITypedResponseWithErrorMessage<T> extends ITypedResponse<T> {
message?: string
+3 -4
View File
@@ -1,8 +1,7 @@
import * as core from '@actions/core'
import {HttpCodes, HttpClientError} from '@actions/http-client'
import {
IHttpClientResponse,
ITypedResponse
IHttpClientResponse
} from '@actions/http-client/interfaces'
import {DefaultRetryDelay, DefaultRetryAttempts} from './constants'
import {ITypedResponseWithErrorMessage} from './contracts'
@@ -113,8 +112,8 @@ export async function retryTypedResponse<T>(
statusCode: error.statusCode,
result: null,
headers: {},
message:error.message,
typeKey:error.result.typeKey
message: error.message,
typeKey: error.result.typeKey
}
} else {
return undefined