Skip to content

Commit

Permalink
Catch error when failing to delete temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
eliangcs committed Dec 3, 2021
1 parent 384dec2 commit 3c96c45
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/core/src/tools/create-file-stasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ const resolveRemoteStream = async (stream) => {
try {
await streamPipeline(stream, fs.createWriteStream(tmpFilePath));
} catch (error) {
fs.unlinkSync(tmpFilePath);
try {
fs.unlinkSync(tmpFilePath);
} catch (e) {
// File doesn't exist? Probably okay
}
throw error;
}

Expand All @@ -69,7 +73,11 @@ const resolveRemoteStream = async (stream) => {

readStream.on('end', () => {
// Burn after reading
fs.unlinkSync(tmpFilePath);
try {
fs.unlinkSync(tmpFilePath);
} catch (e) {
// TODO: We probably want to log warning here
}
});

return {
Expand Down

0 comments on commit 3c96c45

Please sign in to comment.