@@ -2328,6 +2328,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23282328Object.defineProperty(exports, "__esModule", ({ value: true }));
23292329exports.downloadArtifactInternal = exports.downloadArtifactPublic = exports.streamExtractExternal = void 0;
23302330const promises_1 = __importDefault(__nccwpck_require__(73292));
2331+ const stream = __importStar(__nccwpck_require__(12781));
2332+ const fs_1 = __nccwpck_require__(57147);
2333+ const path = __importStar(__nccwpck_require__(71017));
23312334const github = __importStar(__nccwpck_require__(21260));
23322335const core = __importStar(__nccwpck_require__(42186));
23332336const httpClient = __importStar(__nccwpck_require__(96255));
@@ -2368,6 +2371,9 @@ function streamExtract(url, directory) {
23682371 return;
23692372 }
23702373 catch (error) {
2374+ if (error.message.includes('Malformed extraction path')) {
2375+ throw new Error(`Artifact download failed with unretryable error: ${error.message}`);
2376+ }
23712377 retryCount++;
23722378 core.debug(`Failed to download artifact after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`);
23732379 // wait 5 seconds before retrying
@@ -2390,6 +2396,8 @@ function streamExtractExternal(url, directory) {
23902396 response.message.destroy(new Error(`Blob storage chunk did not respond in ${timeout}ms`));
23912397 };
23922398 const timer = setTimeout(timerFn, timeout);
2399+ const createdDirectories = new Set();
2400+ createdDirectories.add(directory);
23932401 response.message
23942402 .on('data', () => {
23952403 timer.refresh();
@@ -2399,11 +2407,47 @@ function streamExtractExternal(url, directory) {
23992407 clearTimeout(timer);
24002408 reject(error);
24012409 })
2402- .pipe(unzip_stream_1.default.Extract({ path: directory }))
2403- .on('close', () => {
2410+ .pipe(unzip_stream_1.default.Parse())
2411+ .pipe(new stream.Transform({
2412+ objectMode: true,
2413+ transform: (entry, _, callback) => __awaiter(this, void 0, void 0, function* () {
2414+ const fullPath = path.normalize(path.join(directory, entry.path));
2415+ if (!directory.endsWith(path.sep)) {
2416+ directory += path.sep;
2417+ }
2418+ if (!fullPath.startsWith(directory)) {
2419+ reject(new Error(`Malformed extraction path: ${fullPath}`));
2420+ }
2421+ if (entry.type === 'Directory') {
2422+ if (!createdDirectories.has(fullPath)) {
2423+ createdDirectories.add(fullPath);
2424+ yield resolveOrCreateDirectory(fullPath).then(() => {
2425+ entry.autodrain();
2426+ callback();
2427+ });
2428+ }
2429+ else {
2430+ entry.autodrain();
2431+ callback();
2432+ }
2433+ }
2434+ else {
2435+ core.info(`Extracting artifact entry: ${fullPath}`);
2436+ if (!createdDirectories.has(path.dirname(fullPath))) {
2437+ createdDirectories.add(path.dirname(fullPath));
2438+ yield resolveOrCreateDirectory(path.dirname(fullPath));
2439+ }
2440+ const writeStream = (0, fs_1.createWriteStream)(fullPath);
2441+ writeStream.on('finish', callback);
2442+ writeStream.on('error', reject);
2443+ entry.pipe(writeStream);
2444+ }
2445+ })
2446+ }))
2447+ .on('finish', () => __awaiter(this, void 0, void 0, function* () {
24042448 clearTimeout(timer);
24052449 resolve();
2406- })
2450+ }))
24072451 .on('error', (error) => {
24082452 reject(error);
24092453 });
@@ -99049,6 +99093,9 @@ function httpRedirectFetch (fetchParams, response) {
9904999093 // https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name
9905099094 request.headersList.delete('authorization')
9905199095
99096+ // https://fetch.spec.whatwg.org/#authentication-entries
99097+ request.headersList.delete('proxy-authorization', true)
99098+
9905299099 // "Cookie" and "Host" are forbidden request-headers, which undici doesn't implement.
9905399100 request.headersList.delete('cookie')
9905499101 request.headersList.delete('host')
@@ -125015,7 +125062,7 @@ exports.unescape = unescape;
125015125062/***/ ((module) => {
125016125063
125017125064"use strict";
125018- module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.1","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^5.3.1","crypto":"^1.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
125065+ module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.4","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^5.3.1","crypto":"^1.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
125019125066
125020125067/***/ }),
125021125068
0 commit comments