Making the save file dialog sync to ensure working properly on MacOS and others

This commit is contained in:
gpatarin
2019-11-09 23:43:03 +01:00
parent 0198d7493d
commit 600646b6ce

View File

@@ -299,15 +299,15 @@ module.exports = class TorrentListController {
] ]
} }
electron.remote.dialog.showSaveDialog(win, opts, function (savePath) { const savePath = electron.remote.dialog.showSaveDialogSync(win, opts)
console.log('Saving torrent ' + torrentKey + ' to ' + savePath)
if (!savePath) return // They clicked Cancel console.log('Saving torrent ' + torrentKey + ' to ' + savePath)
const torrentPath = TorrentSummary.getTorrentPath(torrentSummary) if (!savePath) return // They clicked Cancel
fs.readFile(torrentPath, function (err, torrentFile) { 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) if (err) return dispatch('error', err)
fs.writeFile(savePath, torrentFile, function (err) {
if (err) return dispatch('error', err)
})
}) })
}) })
} }