From 381087208c6ec1d0beb3210f41f54ac6a1dc03ea Mon Sep 17 00:00:00 2001 From: DC Date: Sat, 19 Mar 2016 18:48:58 -0700 Subject: [PATCH] Fix opening files and folders --- main/ipc.js | 5 +++++ renderer/index.js | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/main/ipc.js b/main/ipc.js index 0b2fe1ad..08e305ff 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -50,6 +50,11 @@ function init () { windows.main.setTitle(title) }) + ipcMain.on('openItem', function (e, path) { + console.log('opening file or folder: ' + path) + electron.shell.openItem(path) + }) + ipcMain.on('blockPowerSave', blockPowerSave) ipcMain.on('unblockPowerSave', unblockPowerSave) diff --git a/renderer/index.js b/renderer/index.js index 91d668a6..4ed209bb 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -564,7 +564,14 @@ function openFolder (torrentSummary) { if (!torrent) return var folderPath = path.join(torrent.path, torrent.name) - ipcRenderer.send('openItem', folderPath) + // Multi-file torrents create their own folder, single file torrents just + // drop the file directly into the Downloads folder + fs.stat(folderPath, function (err, stats) { + if (err || !stats.isDirectory()) { + folderPath = torrent.path + } + ipcRenderer.send('openItem', folderPath) + }) } function closePlayer () {