From 600646b6cee6de4112d7d91afe5cf36bf6a00800 Mon Sep 17 00:00:00 2001 From: gpatarin Date: Sat, 9 Nov 2019 23:43:03 +0100 Subject: [PATCH] Making the save file dialog sync to ensure working properly on MacOS and others --- .../controllers/torrent-list-controller.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/renderer/controllers/torrent-list-controller.js b/src/renderer/controllers/torrent-list-controller.js index b723cf4d..1fa9f98a 100644 --- a/src/renderer/controllers/torrent-list-controller.js +++ b/src/renderer/controllers/torrent-list-controller.js @@ -299,15 +299,15 @@ module.exports = class TorrentListController { ] } - electron.remote.dialog.showSaveDialog(win, opts, function (savePath) { - console.log('Saving torrent ' + torrentKey + ' to ' + savePath) - if (!savePath) return // They clicked Cancel - const torrentPath = TorrentSummary.getTorrentPath(torrentSummary) - fs.readFile(torrentPath, function (err, torrentFile) { + const savePath = electron.remote.dialog.showSaveDialogSync(win, opts) + + console.log('Saving torrent ' + torrentKey + ' to ' + savePath) + if (!savePath) return // They clicked Cancel + const torrentPath = TorrentSummary.getTorrentPath(torrentSummary) + fs.readFile(torrentPath, function (err, torrentFile) { + if (err) return dispatch('error', err) + fs.writeFile(savePath, torrentFile, function (err) { if (err) return dispatch('error', err) - fs.writeFile(savePath, torrentFile, function (err) { - if (err) return dispatch('error', err) - }) }) }) }