Fix opening files and folders

This commit is contained in:
DC
2016-03-19 18:48:58 -07:00
parent b129fc3b4c
commit 381087208c
2 changed files with 13 additions and 1 deletions

View File

@@ -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)

View File

@@ -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 () {