From d53177898a785f6fd4707830908c3be20e29bdd0 Mon Sep 17 00:00:00 2001 From: Oj Date: Sat, 11 Dec 2021 19:51:14 +0000 Subject: [PATCH] [AsarUpdate] Handle write error without erroring fully --- src/asarUpdate.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/asarUpdate.js b/src/asarUpdate.js index 07ac5db..c9a88b2 100644 --- a/src/asarUpdate.js +++ b/src/asarUpdate.js @@ -25,6 +25,15 @@ module.exports = () => { // (Try) update asar log('AsarUpdate', 'Original Hash:', originalHash); const file = fs.createWriteStream(asarPath); + + let writeError = false; + file.on('error', err => { + log('AsarUpdate', 'Failed to write', err); + file.close(); + + writeError = true; + }); + log('AsarUpdate', 'Opened write stream to asar'); request(asarUrl, (_err, res) => { @@ -61,5 +70,9 @@ Changed: ${changed}`); electron.app.exit(); } } + + if (writeError) { + // Warn message? + } }); }; \ No newline at end of file