Replace downloadCacheFile with downloadCacheStorageSDK

This commit is contained in:
Bassem Dghaidi
2024-11-27 04:51:21 -08:00
committed by GitHub
parent b050504b2d
commit 27e5cf2514
3 changed files with 59 additions and 50 deletions

View File

@@ -3,6 +3,7 @@ import * as path from 'path'
import * as utils from './internal/cacheUtils'
import * as cacheHttpClient from './internal/cacheHttpClient'
import * as cacheTwirpClient from './internal/shared/cacheTwirpClient'
import {downloadCacheStorageSDK} from './internal/downloadUtils'
import {getCacheServiceVersion, isGhes} from './internal/config'
import {DownloadOptions, UploadOptions} from './options'
import {createTar, extractTar, listTar} from './internal/tar'
@@ -14,7 +15,6 @@ import {
} from './generated/results/api/v1/cache'
import {CacheFileSizeLimit} from './internal/constants'
import {uploadCacheFile} from './internal/blob/upload-cache'
import {downloadCacheFile} from './internal/blob/download-cache'
export class ValidationError extends Error {
constructor(message: string) {
super(message)
@@ -161,11 +161,14 @@ async function restoreCacheV1(
)
core.debug(`Archive Path: ${archivePath}`)
// Download the cache from the cache entry
// Download the cache archive from from blob storage
await cacheHttpClient.downloadCache(
cacheEntry.archiveLocation,
archivePath,
options
options ||
({
timeoutInMs: 30000
} as DownloadOptions)
)
if (core.isDebug()) {
@@ -271,11 +274,14 @@ async function restoreCacheV2(
core.debug(`Archive path: ${archivePath}`)
core.debug(`Starting download of archive to: ${archivePath}`)
const downloadResponse = await downloadCacheFile(
await downloadCacheStorageSDK(
response.signedDownloadUrl,
archivePath
archivePath,
options ||
({
timeoutInMs: 30000
} as DownloadOptions)
)
core.debug(`Download response status: ${downloadResponse._response.status}`)
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath)
core.info(

View File

@@ -22,10 +22,24 @@ export async function downloadCacheFile(
`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`
)
return blockBlobClient.downloadToFile(
const response = await blockBlobClient.downloadToFile(
archivePath,
0,
undefined,
downloadOptions
)
switch (response._response.status) {
case 200:
core.info(`Cache downloaded from "${signedUploadURL}"`)
break
case 304:
core.info(`Cache not found at "${signedUploadURL}"`)
break
default:
core.info(`Unexpected HTTP response: ${response._response.status}`)
break
}
return response
}