mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 09:40:17 +08:00
Add more error handling to zstd extraction
This commit is contained in:
43
src/tar.ts
43
src/tar.ts
@@ -153,25 +153,32 @@ export async function extractTarZst(
|
||||
|
||||
process.stdout.write(`[command]tar ${args.join(" ")}\n`);
|
||||
|
||||
const tarProcess = spawn("tar", args, { stdio: "pipe" });
|
||||
let stdout = "";
|
||||
tarProcess.stdout?.on("data", (data: Buffer) => {
|
||||
stdout += data.toString();
|
||||
process.stdout.write(data);
|
||||
});
|
||||
|
||||
let stderr = "";
|
||||
tarProcess.stderr?.on("data", (data: Buffer) => {
|
||||
stderr += data.toString();
|
||||
// Mimic the standard behavior of the toolrunner by writing stderr to stdout
|
||||
process.stdout.write(data);
|
||||
});
|
||||
|
||||
if (tar instanceof stream.Readable) {
|
||||
tar.pipe(tarProcess.stdin);
|
||||
}
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const tarProcess = spawn("tar", args, { stdio: "pipe" });
|
||||
|
||||
let stdout = "";
|
||||
tarProcess.stdout?.on("data", (data: Buffer) => {
|
||||
stdout += data.toString();
|
||||
process.stdout.write(data);
|
||||
});
|
||||
|
||||
let stderr = "";
|
||||
tarProcess.stderr?.on("data", (data: Buffer) => {
|
||||
stderr += data.toString();
|
||||
// Mimic the standard behavior of the toolrunner by writing stderr to stdout
|
||||
process.stdout.write(data);
|
||||
});
|
||||
|
||||
tarProcess.on("error", (err) => {
|
||||
reject(new Error(`Error while extracting tar: ${err}`));
|
||||
});
|
||||
|
||||
if (tar instanceof stream.Readable) {
|
||||
tar.pipe(tarProcess.stdin).on("error", (err) => {
|
||||
reject(new Error(`Error while piping tar stream: ${err}`));
|
||||
});
|
||||
}
|
||||
|
||||
tarProcess.on("exit", (code) => {
|
||||
if (code !== 0) {
|
||||
reject(
|
||||
|
||||
@@ -224,7 +224,7 @@ export function writeToolcacheMarkerFile(
|
||||
): void {
|
||||
const markerFilePath = `${extractedPath}.complete`;
|
||||
fs.writeFileSync(markerFilePath, "");
|
||||
logger.debug(`Wrote marker file to ${markerFilePath}`);
|
||||
logger.info(`Wrote toolcache marker file to ${markerFilePath}`);
|
||||
}
|
||||
|
||||
function sanitizeUrlForStatusReport(url: string): string {
|
||||
|
||||
Reference in New Issue
Block a user