From 8b2d33ac0a4d18f5ae31b23dcd538e443c4158f5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 1 Apr 2019 13:24:17 -0600 Subject: [PATCH] Don't try to save files the user didn't want to save Fixes https://github.com/vector-im/riot-web/issues/9350 --- electron_app/src/webcontents-handler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/electron_app/src/webcontents-handler.js b/electron_app/src/webcontents-handler.js index a437f0fa..4bfb7876 100644 --- a/electron_app/src/webcontents-handler.js +++ b/electron_app/src/webcontents-handler.js @@ -96,13 +96,14 @@ function onLinkContextMenu(ev, params) { defaultPath: targetFileName, }); + if (!filePath) return; // user cancelled dialog + try { if (url.startsWith("data:")) { fs.writeFileSync(filePath, nativeImage.createFromDataURL(url)); } else { request.get(url).pipe(fs.createWriteStream(filePath)); } - } catch (err) { console.error(err); dialog.showMessageBox({