This commit is contained in:
Michael Telatynski 2022-11-30 16:52:15 +00:00
parent fa1941278e
commit c2871033c2
No known key found for this signature in database
GPG key ID: 98BC6A2B829297FE

View file

@ -27,7 +27,10 @@ async function downloadToFile(url, filename) {
if (!resp.body) throw new Error(`unexpected response has no body ${resp.statusText}`);
await pipeline(resp.body, fs.createWriteStream(filename));
} catch (e) {
await fsPromises.unlink(filename).catch();
console.error(e);
try {
await fsPromises.unlink(filename);
} catch (_) {}
throw e;
}
}