mirror of
https://github.com/actions/toolkit.git
synced 2026-08-11 00:00:28 +02:00
Revert "T dedah/cache size" (#1042)
This commit is contained in:
+4
-6
@@ -13,8 +13,7 @@ import {
|
||||
InternalCacheOptions,
|
||||
CommitCacheRequest,
|
||||
ReserveCacheRequest,
|
||||
ReserveCacheResponse,
|
||||
ITypedResponseWithErrorMessage
|
||||
ReserveCacheResponse
|
||||
} from './contracts'
|
||||
import {downloadCacheHttpClient, downloadCacheStorageSDK} from './downloadUtils'
|
||||
import {
|
||||
@@ -144,14 +143,13 @@ export async function reserveCache(
|
||||
key: string,
|
||||
paths: string[],
|
||||
options?: InternalCacheOptions
|
||||
): Promise<ITypedResponseWithErrorMessage<ReserveCacheResponse>> {
|
||||
): Promise<number> {
|
||||
const httpClient = createHttpClient()
|
||||
const version = getCacheVersion(paths, options?.compressionMethod)
|
||||
|
||||
const reserveCacheRequest: ReserveCacheRequest = {
|
||||
key,
|
||||
version,
|
||||
cacheSize: options?.cacheSize
|
||||
version
|
||||
}
|
||||
const response = await retryTypedResponse('reserveCache', async () =>
|
||||
httpClient.postJson<ReserveCacheResponse>(
|
||||
@@ -159,7 +157,7 @@ export async function reserveCache(
|
||||
reserveCacheRequest
|
||||
)
|
||||
)
|
||||
return response
|
||||
return response?.result?.cacheId ?? -1
|
||||
}
|
||||
|
||||
function getContentRange(start: number, end: number): string {
|
||||
|
||||
-7
@@ -123,10 +123,3 @@ export function assertDefined<T>(name: string, value?: T): T {
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
export function isGhes(): boolean {
|
||||
const ghUrl = new URL(
|
||||
process.env["GITHUB_SERVER_URL"] || "https://github.com"
|
||||
);
|
||||
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||
}
|
||||
|
||||
-8
@@ -1,10 +1,4 @@
|
||||
import {CompressionMethod} from './constants'
|
||||
import {ITypedResponse} from '@actions/http-client/interfaces'
|
||||
import {HttpClientError} from '@actions/http-client'
|
||||
|
||||
export interface ITypedResponseWithErrorMessage<T> extends ITypedResponse<T> {
|
||||
error?: HttpClientError
|
||||
}
|
||||
|
||||
export interface ArtifactCacheEntry {
|
||||
cacheKey?: string
|
||||
@@ -20,7 +14,6 @@ export interface CommitCacheRequest {
|
||||
export interface ReserveCacheRequest {
|
||||
key: string
|
||||
version?: string
|
||||
cacheSize?: number
|
||||
}
|
||||
|
||||
export interface ReserveCacheResponse {
|
||||
@@ -29,5 +22,4 @@ export interface ReserveCacheResponse {
|
||||
|
||||
export interface InternalCacheOptions {
|
||||
compressionMethod?: CompressionMethod
|
||||
cacheSize?: number
|
||||
}
|
||||
|
||||
+8
-7
@@ -1,8 +1,10 @@
|
||||
import * as core from '@actions/core'
|
||||
import {HttpCodes, HttpClientError} from '@actions/http-client'
|
||||
import {IHttpClientResponse} from '@actions/http-client/interfaces'
|
||||
import {
|
||||
IHttpClientResponse,
|
||||
ITypedResponse
|
||||
} from '@actions/http-client/interfaces'
|
||||
import {DefaultRetryDelay, DefaultRetryAttempts} from './constants'
|
||||
import {ITypedResponseWithErrorMessage} from './contracts'
|
||||
|
||||
export function isSuccessStatusCode(statusCode?: number): boolean {
|
||||
if (!statusCode) {
|
||||
@@ -92,14 +94,14 @@ export async function retry<T>(
|
||||
|
||||
export async function retryTypedResponse<T>(
|
||||
name: string,
|
||||
method: () => Promise<ITypedResponseWithErrorMessage<T>>,
|
||||
method: () => Promise<ITypedResponse<T>>,
|
||||
maxAttempts = DefaultRetryAttempts,
|
||||
delay = DefaultRetryDelay
|
||||
): Promise<ITypedResponseWithErrorMessage<T>> {
|
||||
): Promise<ITypedResponse<T>> {
|
||||
return await retry(
|
||||
name,
|
||||
method,
|
||||
(response: ITypedResponseWithErrorMessage<T>) => response.statusCode,
|
||||
(response: ITypedResponse<T>) => response.statusCode,
|
||||
maxAttempts,
|
||||
delay,
|
||||
// If the error object contains the statusCode property, extract it and return
|
||||
@@ -109,8 +111,7 @@ export async function retryTypedResponse<T>(
|
||||
return {
|
||||
statusCode: error.statusCode,
|
||||
result: null,
|
||||
headers: {},
|
||||
error: error
|
||||
headers: {}
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
|
||||
Reference in New Issue
Block a user