mirror of https://github.com/actions/cache.git
Use DownloadCacheFile for blob downloads
This commit is contained in:
parent
0968f23612
commit
cf539bd9ee
|
@ -27687,6 +27687,7 @@ const cacheHttpClient = __importStar(__nccwpck_require__(42370));
|
|||
const cacheTwirpClient = __importStar(__nccwpck_require__(95451));
|
||||
const tar_1 = __nccwpck_require__(49099);
|
||||
const upload_cache_1 = __nccwpck_require__(47107);
|
||||
const download_cache_1 = __nccwpck_require__(9049);
|
||||
const util_1 = __nccwpck_require__(49196);
|
||||
const constants_1 = __nccwpck_require__(74010);
|
||||
class ValidationError extends Error {
|
||||
|
@ -27882,8 +27883,8 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Starting download of artifact to: ${archivePath}`);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
// Download the cache from the cache entry
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
// Attempt to download the cache file from ABS
|
||||
yield (0, download_cache_1.DownloadCacheFile)(response.signedDownloadUrl, archivePath);
|
||||
yield (0, tar_1.extractTar)(archivePath, compressionMethod);
|
||||
core.info('Cache restored successfully');
|
||||
return request.key;
|
||||
|
@ -27899,6 +27900,7 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Failed to delete archive: ${error}`);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -31325,6 +31327,126 @@ exports.createTar = createTar;
|
|||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9049:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DownloadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(74850));
|
||||
// import * as httpClient from '@actions/http-client'
|
||||
// import unzip from 'unzip-stream'
|
||||
const storage_blob_1 = __nccwpck_require__(33864);
|
||||
// const packageJson = require('../../../package.json')
|
||||
function DownloadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const downloadOptions = {
|
||||
maxRetryRequests: 5,
|
||||
};
|
||||
// Specify data transfer options
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${JSON.stringify(blobClient)}`);
|
||||
core.debug(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
|
||||
return blockBlobClient.downloadToFile(archivePath, 0, undefined, downloadOptions);
|
||||
});
|
||||
}
|
||||
exports.DownloadCacheFile = DownloadCacheFile;
|
||||
// export async function StreamExtract(url: string, directory: string): Promise<void> {
|
||||
// let retryCount = 0
|
||||
// while (retryCount < 5) {
|
||||
// try {
|
||||
// await streamExtractExternal(url, directory)
|
||||
// return
|
||||
// } catch (error) {
|
||||
// retryCount++
|
||||
// core.info(
|
||||
// `Failed to download cache after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`
|
||||
// )
|
||||
// // wait 5 seconds before retrying
|
||||
// await new Promise(resolve => setTimeout(resolve, 5000))
|
||||
// }
|
||||
// }
|
||||
// throw new Error(`Cache download failed after ${retryCount} retries.`)
|
||||
// }
|
||||
// export async function streamExtractExternal(
|
||||
// url: string,
|
||||
// directory: string
|
||||
// ): Promise<void> {
|
||||
// const client = new httpClient.HttpClient(`@actions/cache-${packageJson.version}`)
|
||||
// const response = await client.get(url)
|
||||
// if (response.message.statusCode !== 200) {
|
||||
// core.info(`Failed to download cache. HTTP status code: ${response.message.statusCode}`)
|
||||
// throw new Error(
|
||||
// `Unexpected HTTP response from blob storage: ${response.message.statusCode} ${response.message.statusMessage}`
|
||||
// )
|
||||
// }
|
||||
// const timeout = 30 * 1000 // 30 seconds
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const timerFn = (): void => {
|
||||
// response.message.destroy(
|
||||
// new Error(`Blob storage chunk did not respond in ${timeout}ms`)
|
||||
// )
|
||||
// }
|
||||
// const timer = setTimeout(timerFn, timeout)
|
||||
// response.message
|
||||
// .on('data', () => {
|
||||
// timer.refresh()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// core.info(
|
||||
// `response.message: Cache download failed: ${error.message}`
|
||||
// )
|
||||
// clearTimeout(timer)
|
||||
// reject(error)
|
||||
// })
|
||||
// .pipe(unzip.Extract({ path: directory }))
|
||||
// .on('close', () => {
|
||||
// clearTimeout(timer)
|
||||
// resolve()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// reject(error)
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
//# sourceMappingURL=download-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 47107:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
|
|
|
@ -27687,6 +27687,7 @@ const cacheHttpClient = __importStar(__nccwpck_require__(42370));
|
|||
const cacheTwirpClient = __importStar(__nccwpck_require__(95451));
|
||||
const tar_1 = __nccwpck_require__(49099);
|
||||
const upload_cache_1 = __nccwpck_require__(47107);
|
||||
const download_cache_1 = __nccwpck_require__(9049);
|
||||
const util_1 = __nccwpck_require__(49196);
|
||||
const constants_1 = __nccwpck_require__(74010);
|
||||
class ValidationError extends Error {
|
||||
|
@ -27882,8 +27883,8 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Starting download of artifact to: ${archivePath}`);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
// Download the cache from the cache entry
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
// Attempt to download the cache file from ABS
|
||||
yield (0, download_cache_1.DownloadCacheFile)(response.signedDownloadUrl, archivePath);
|
||||
yield (0, tar_1.extractTar)(archivePath, compressionMethod);
|
||||
core.info('Cache restored successfully');
|
||||
return request.key;
|
||||
|
@ -27899,6 +27900,7 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Failed to delete archive: ${error}`);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -31325,6 +31327,126 @@ exports.createTar = createTar;
|
|||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9049:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DownloadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(74850));
|
||||
// import * as httpClient from '@actions/http-client'
|
||||
// import unzip from 'unzip-stream'
|
||||
const storage_blob_1 = __nccwpck_require__(33864);
|
||||
// const packageJson = require('../../../package.json')
|
||||
function DownloadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const downloadOptions = {
|
||||
maxRetryRequests: 5,
|
||||
};
|
||||
// Specify data transfer options
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${JSON.stringify(blobClient)}`);
|
||||
core.debug(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
|
||||
return blockBlobClient.downloadToFile(archivePath, 0, undefined, downloadOptions);
|
||||
});
|
||||
}
|
||||
exports.DownloadCacheFile = DownloadCacheFile;
|
||||
// export async function StreamExtract(url: string, directory: string): Promise<void> {
|
||||
// let retryCount = 0
|
||||
// while (retryCount < 5) {
|
||||
// try {
|
||||
// await streamExtractExternal(url, directory)
|
||||
// return
|
||||
// } catch (error) {
|
||||
// retryCount++
|
||||
// core.info(
|
||||
// `Failed to download cache after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`
|
||||
// )
|
||||
// // wait 5 seconds before retrying
|
||||
// await new Promise(resolve => setTimeout(resolve, 5000))
|
||||
// }
|
||||
// }
|
||||
// throw new Error(`Cache download failed after ${retryCount} retries.`)
|
||||
// }
|
||||
// export async function streamExtractExternal(
|
||||
// url: string,
|
||||
// directory: string
|
||||
// ): Promise<void> {
|
||||
// const client = new httpClient.HttpClient(`@actions/cache-${packageJson.version}`)
|
||||
// const response = await client.get(url)
|
||||
// if (response.message.statusCode !== 200) {
|
||||
// core.info(`Failed to download cache. HTTP status code: ${response.message.statusCode}`)
|
||||
// throw new Error(
|
||||
// `Unexpected HTTP response from blob storage: ${response.message.statusCode} ${response.message.statusMessage}`
|
||||
// )
|
||||
// }
|
||||
// const timeout = 30 * 1000 // 30 seconds
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const timerFn = (): void => {
|
||||
// response.message.destroy(
|
||||
// new Error(`Blob storage chunk did not respond in ${timeout}ms`)
|
||||
// )
|
||||
// }
|
||||
// const timer = setTimeout(timerFn, timeout)
|
||||
// response.message
|
||||
// .on('data', () => {
|
||||
// timer.refresh()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// core.info(
|
||||
// `response.message: Cache download failed: ${error.message}`
|
||||
// )
|
||||
// clearTimeout(timer)
|
||||
// reject(error)
|
||||
// })
|
||||
// .pipe(unzip.Extract({ path: directory }))
|
||||
// .on('close', () => {
|
||||
// clearTimeout(timer)
|
||||
// resolve()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// reject(error)
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
//# sourceMappingURL=download-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 47107:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
|
|
|
@ -27687,6 +27687,7 @@ const cacheHttpClient = __importStar(__nccwpck_require__(42370));
|
|||
const cacheTwirpClient = __importStar(__nccwpck_require__(95451));
|
||||
const tar_1 = __nccwpck_require__(49099);
|
||||
const upload_cache_1 = __nccwpck_require__(47107);
|
||||
const download_cache_1 = __nccwpck_require__(9049);
|
||||
const util_1 = __nccwpck_require__(49196);
|
||||
const constants_1 = __nccwpck_require__(74010);
|
||||
class ValidationError extends Error {
|
||||
|
@ -27882,8 +27883,8 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Starting download of artifact to: ${archivePath}`);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
// Download the cache from the cache entry
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
// Attempt to download the cache file from ABS
|
||||
yield (0, download_cache_1.DownloadCacheFile)(response.signedDownloadUrl, archivePath);
|
||||
yield (0, tar_1.extractTar)(archivePath, compressionMethod);
|
||||
core.info('Cache restored successfully');
|
||||
return request.key;
|
||||
|
@ -27899,6 +27900,7 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Failed to delete archive: ${error}`);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -31325,6 +31327,126 @@ exports.createTar = createTar;
|
|||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9049:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DownloadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(74850));
|
||||
// import * as httpClient from '@actions/http-client'
|
||||
// import unzip from 'unzip-stream'
|
||||
const storage_blob_1 = __nccwpck_require__(33864);
|
||||
// const packageJson = require('../../../package.json')
|
||||
function DownloadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const downloadOptions = {
|
||||
maxRetryRequests: 5,
|
||||
};
|
||||
// Specify data transfer options
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${JSON.stringify(blobClient)}`);
|
||||
core.debug(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
|
||||
return blockBlobClient.downloadToFile(archivePath, 0, undefined, downloadOptions);
|
||||
});
|
||||
}
|
||||
exports.DownloadCacheFile = DownloadCacheFile;
|
||||
// export async function StreamExtract(url: string, directory: string): Promise<void> {
|
||||
// let retryCount = 0
|
||||
// while (retryCount < 5) {
|
||||
// try {
|
||||
// await streamExtractExternal(url, directory)
|
||||
// return
|
||||
// } catch (error) {
|
||||
// retryCount++
|
||||
// core.info(
|
||||
// `Failed to download cache after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`
|
||||
// )
|
||||
// // wait 5 seconds before retrying
|
||||
// await new Promise(resolve => setTimeout(resolve, 5000))
|
||||
// }
|
||||
// }
|
||||
// throw new Error(`Cache download failed after ${retryCount} retries.`)
|
||||
// }
|
||||
// export async function streamExtractExternal(
|
||||
// url: string,
|
||||
// directory: string
|
||||
// ): Promise<void> {
|
||||
// const client = new httpClient.HttpClient(`@actions/cache-${packageJson.version}`)
|
||||
// const response = await client.get(url)
|
||||
// if (response.message.statusCode !== 200) {
|
||||
// core.info(`Failed to download cache. HTTP status code: ${response.message.statusCode}`)
|
||||
// throw new Error(
|
||||
// `Unexpected HTTP response from blob storage: ${response.message.statusCode} ${response.message.statusMessage}`
|
||||
// )
|
||||
// }
|
||||
// const timeout = 30 * 1000 // 30 seconds
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const timerFn = (): void => {
|
||||
// response.message.destroy(
|
||||
// new Error(`Blob storage chunk did not respond in ${timeout}ms`)
|
||||
// )
|
||||
// }
|
||||
// const timer = setTimeout(timerFn, timeout)
|
||||
// response.message
|
||||
// .on('data', () => {
|
||||
// timer.refresh()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// core.info(
|
||||
// `response.message: Cache download failed: ${error.message}`
|
||||
// )
|
||||
// clearTimeout(timer)
|
||||
// reject(error)
|
||||
// })
|
||||
// .pipe(unzip.Extract({ path: directory }))
|
||||
// .on('close', () => {
|
||||
// clearTimeout(timer)
|
||||
// resolve()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// reject(error)
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
//# sourceMappingURL=download-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 47107:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
|
|
|
@ -27687,6 +27687,7 @@ const cacheHttpClient = __importStar(__nccwpck_require__(42370));
|
|||
const cacheTwirpClient = __importStar(__nccwpck_require__(95451));
|
||||
const tar_1 = __nccwpck_require__(49099);
|
||||
const upload_cache_1 = __nccwpck_require__(47107);
|
||||
const download_cache_1 = __nccwpck_require__(9049);
|
||||
const util_1 = __nccwpck_require__(49196);
|
||||
const constants_1 = __nccwpck_require__(74010);
|
||||
class ValidationError extends Error {
|
||||
|
@ -27882,8 +27883,8 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Starting download of artifact to: ${archivePath}`);
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
// Download the cache from the cache entry
|
||||
yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options);
|
||||
// Attempt to download the cache file from ABS
|
||||
yield (0, download_cache_1.DownloadCacheFile)(response.signedDownloadUrl, archivePath);
|
||||
yield (0, tar_1.extractTar)(archivePath, compressionMethod);
|
||||
core.info('Cache restored successfully');
|
||||
return request.key;
|
||||
|
@ -27899,6 +27900,7 @@ function restoreCachev2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
|
|||
core.debug(`Failed to delete archive: ${error}`);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -31325,6 +31327,126 @@ exports.createTar = createTar;
|
|||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9049:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DownloadCacheFile = void 0;
|
||||
const core = __importStar(__nccwpck_require__(74850));
|
||||
// import * as httpClient from '@actions/http-client'
|
||||
// import unzip from 'unzip-stream'
|
||||
const storage_blob_1 = __nccwpck_require__(33864);
|
||||
// const packageJson = require('../../../package.json')
|
||||
function DownloadCacheFile(signedUploadURL, archivePath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const downloadOptions = {
|
||||
maxRetryRequests: 5,
|
||||
};
|
||||
// Specify data transfer options
|
||||
const blobClient = new storage_blob_1.BlobClient(signedUploadURL);
|
||||
const blockBlobClient = blobClient.getBlockBlobClient();
|
||||
core.debug(`BlobClient: ${JSON.stringify(blobClient)}`);
|
||||
core.debug(`blockBlobClient: ${JSON.stringify(blockBlobClient)}`);
|
||||
return blockBlobClient.downloadToFile(archivePath, 0, undefined, downloadOptions);
|
||||
});
|
||||
}
|
||||
exports.DownloadCacheFile = DownloadCacheFile;
|
||||
// export async function StreamExtract(url: string, directory: string): Promise<void> {
|
||||
// let retryCount = 0
|
||||
// while (retryCount < 5) {
|
||||
// try {
|
||||
// await streamExtractExternal(url, directory)
|
||||
// return
|
||||
// } catch (error) {
|
||||
// retryCount++
|
||||
// core.info(
|
||||
// `Failed to download cache after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`
|
||||
// )
|
||||
// // wait 5 seconds before retrying
|
||||
// await new Promise(resolve => setTimeout(resolve, 5000))
|
||||
// }
|
||||
// }
|
||||
// throw new Error(`Cache download failed after ${retryCount} retries.`)
|
||||
// }
|
||||
// export async function streamExtractExternal(
|
||||
// url: string,
|
||||
// directory: string
|
||||
// ): Promise<void> {
|
||||
// const client = new httpClient.HttpClient(`@actions/cache-${packageJson.version}`)
|
||||
// const response = await client.get(url)
|
||||
// if (response.message.statusCode !== 200) {
|
||||
// core.info(`Failed to download cache. HTTP status code: ${response.message.statusCode}`)
|
||||
// throw new Error(
|
||||
// `Unexpected HTTP response from blob storage: ${response.message.statusCode} ${response.message.statusMessage}`
|
||||
// )
|
||||
// }
|
||||
// const timeout = 30 * 1000 // 30 seconds
|
||||
// return new Promise((resolve, reject) => {
|
||||
// const timerFn = (): void => {
|
||||
// response.message.destroy(
|
||||
// new Error(`Blob storage chunk did not respond in ${timeout}ms`)
|
||||
// )
|
||||
// }
|
||||
// const timer = setTimeout(timerFn, timeout)
|
||||
// response.message
|
||||
// .on('data', () => {
|
||||
// timer.refresh()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// core.info(
|
||||
// `response.message: Cache download failed: ${error.message}`
|
||||
// )
|
||||
// clearTimeout(timer)
|
||||
// reject(error)
|
||||
// })
|
||||
// .pipe(unzip.Extract({ path: directory }))
|
||||
// .on('close', () => {
|
||||
// clearTimeout(timer)
|
||||
// resolve()
|
||||
// })
|
||||
// .on('error', (error: Error) => {
|
||||
// reject(error)
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
//# sourceMappingURL=download-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 47107:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue