@@ -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__(95438));
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,50 @@ 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+ core.debug(`Extracting artifact entry: ${fullPath}`);
2422+ if (entry.type === 'Directory') {
2423+ if (!createdDirectories.has(fullPath)) {
2424+ createdDirectories.add(fullPath);
2425+ yield resolveOrCreateDirectory(fullPath).then(() => {
2426+ entry.autodrain();
2427+ callback();
2428+ });
2429+ }
2430+ else {
2431+ entry.autodrain();
2432+ callback();
2433+ }
2434+ }
2435+ else {
2436+ if (!createdDirectories.has(path.dirname(fullPath))) {
2437+ createdDirectories.add(path.dirname(fullPath));
2438+ yield resolveOrCreateDirectory(path.dirname(fullPath)).then(() => {
2439+ entry.autodrain();
2440+ callback();
2441+ });
2442+ }
2443+ const writeStream = (0, fs_1.createWriteStream)(fullPath);
2444+ writeStream.on('finish', callback);
2445+ writeStream.on('error', reject);
2446+ entry.pipe(writeStream);
2447+ }
2448+ })
2449+ }))
2450+ .on('finish', () => __awaiter(this, void 0, void 0, function* () {
24042451 clearTimeout(timer);
24052452 resolve();
2406- })
2453+ }))
24072454 .on('error', (error) => {
24082455 reject(error);
24092456 });
@@ -125221,7 +125268,7 @@ exports.unescape = unescape;
125221125268/***/ ((module) => {
125222125269
125223125270"use strict";
125224- 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"}}');
125271+ module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.2","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"}}');
125225125272
125226125273/***/ }),
125227125274
0 commit comments