Merge pull request #9352 from vector-im/travis/save-as-2
Don't try to save files the user didn't want to save
This commit is contained in:
commit
958260d559
1 changed files with 2 additions and 1 deletions
|
@ -96,13 +96,14 @@ function onLinkContextMenu(ev, params) {
|
||||||
defaultPath: targetFileName,
|
defaultPath: targetFileName,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!filePath) return; // user cancelled dialog
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (url.startsWith("data:")) {
|
if (url.startsWith("data:")) {
|
||||||
fs.writeFileSync(filePath, nativeImage.createFromDataURL(url));
|
fs.writeFileSync(filePath, nativeImage.createFromDataURL(url));
|
||||||
} else {
|
} else {
|
||||||
request.get(url).pipe(fs.createWriteStream(filePath));
|
request.get(url).pipe(fs.createWriteStream(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
dialog.showMessageBox({
|
dialog.showMessageBox({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue