Skip to content

Commit b2a4442

Browse files
committed
Ensure destination directory exists when streaming extraction
1 parent d5bcf48 commit b2a4442

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

lib/tar.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tar.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-download.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-download.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ export async function extractTarZst(
175175

176176
if (tar instanceof stream.Readable) {
177177
tar.pipe(tarProcess.stdin).on("error", (err) => {
178-
reject(new Error(`Error while piping tar stream: ${err}`));
178+
reject(
179+
new Error(`Error while downloading and extracting tar: ${err}`),
180+
);
179181
});
180182
}
181183

src/tools-download.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ async function downloadAndExtractZstdWithStreaming(
183183
tarVersion: tar.TarVersion,
184184
logger: Logger,
185185
): Promise<void> {
186+
// Ensure destination exists
187+
fs.mkdirSync(dest, { recursive: true });
188+
189+
// Add User-Agent header and Authorization header if provided.
186190
headers = Object.assign(
187191
{ "User-Agent": "CodeQL Action" },
188192
authorization ? { authorization } : {},
@@ -193,6 +197,7 @@ async function downloadAndExtractZstdWithStreaming(
193197
codeqlURL,
194198
{
195199
headers,
200+
// Increase the high water mark to improve performance.
196201
highWaterMark: STREAMING_HIGH_WATERMARK_BYTES,
197202
} as unknown as RequestOptions,
198203
(r) => resolve(r),

0 commit comments

Comments
 (0)