mirror of
https://github.com/github/codeql-action.git
synced 2025-12-30 19:20:08 +08:00
Ensure destination directory exists when streaming extraction
This commit is contained in:
@@ -175,7 +175,9 @@ export async function extractTarZst(
|
||||
|
||||
if (tar instanceof stream.Readable) {
|
||||
tar.pipe(tarProcess.stdin).on("error", (err) => {
|
||||
reject(new Error(`Error while piping tar stream: ${err}`));
|
||||
reject(
|
||||
new Error(`Error while downloading and extracting tar: ${err}`),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +183,10 @@ async function downloadAndExtractZstdWithStreaming(
|
||||
tarVersion: tar.TarVersion,
|
||||
logger: Logger,
|
||||
): Promise<void> {
|
||||
// Ensure destination exists
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
|
||||
// Add User-Agent header and Authorization header if provided.
|
||||
headers = Object.assign(
|
||||
{ "User-Agent": "CodeQL Action" },
|
||||
authorization ? { authorization } : {},
|
||||
@@ -193,6 +197,7 @@ async function downloadAndExtractZstdWithStreaming(
|
||||
codeqlURL,
|
||||
{
|
||||
headers,
|
||||
// Increase the high water mark to improve performance.
|
||||
highWaterMark: STREAMING_HIGH_WATERMARK_BYTES,
|
||||
} as unknown as RequestOptions,
|
||||
(r) => resolve(r),
|
||||
|
||||
Reference in New Issue
Block a user