Add more error handling to zstd extraction

This commit is contained in:
Henry Mercer
2024-12-03 15:10:08 +00:00
parent d57328a17b
commit d5bcf48469
6 changed files with 49 additions and 37 deletions

View File

@@ -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(

View File

@@ -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 {