Skip to content

Commit

Permalink
Merge pull request #9352 from vector-im/travis/save-as-2
Browse files Browse the repository at this point in the history
Don't try to save files the user didn't want to save
  • Loading branch information
turt2live authored Apr 2, 2019
2 parents 95e247a + 8b2d33a commit 958260d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion electron_app/src/webcontents-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 958260d

Please sign in to comment.