diff --git a/main/index.js b/main/index.js index 5ba8dd2d..92f7dacb 100644 --- a/main/index.js +++ b/main/index.js @@ -148,7 +148,7 @@ function processArgv (argv) { if (pathsToOpen.length > 0) openFilePaths(pathsToOpen) } -// Convert paths to {name, path, size} objects, then send to renderer process +// Send files to the renderer process // Opening files means either adding torrents, creating and seeding a torrent // from files, or adding subtitles function openFilePaths (paths) { diff --git a/main/menu.js b/main/menu.js index c1fd5d3b..6a3b8891 100644 --- a/main/menu.js +++ b/main/menu.js @@ -189,8 +189,7 @@ function showOpenSeedFile () { properties: [ 'openFile' ] }, function (selectedPaths) { if (!Array.isArray(selectedPaths)) return - var selectedPath = selectedPaths[0] - windows.main.send('dispatch', 'showCreateTorrent', selectedPath) + windows.main.send('dispatch', 'showCreateTorrent', selectedPaths) }) } @@ -202,8 +201,7 @@ function showOpenSeedFiles () { properties: [ 'openFile', 'openDirectory' ] }, function (selectedPaths) { if (!Array.isArray(selectedPaths)) return - var selectedPath = selectedPaths[0] - windows.main.send('dispatch', 'showCreateTorrent', selectedPath) + windows.main.send('dispatch', 'showCreateTorrent', selectedPaths) }) } diff --git a/renderer/index.js b/renderer/index.js index 10b0bb0e..0d4acf50 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -228,7 +228,7 @@ function dispatch (action, ...args) { ipcRenderer.send('showOpenTorrentFile') /* open torrent file */ } if (action === 'showCreateTorrent') { - showCreateTorrent(args[0] /* fileOrFolder */) + showCreateTorrent(args[0] /* paths */) } if (action === 'createTorrent') { createTorrent(args[0] /* options */) @@ -803,18 +803,18 @@ function startTorrentingSummary (torrentSummary) { // Shows the Create Torrent page with options to seed a given file or folder function showCreateTorrent (files) { - if (Array.isArray(files)) { - if (files.length === 0 || typeof files[0] !== 'string') { - state.location.go({ - url: 'create-torrent', - files: files - }) - return - } - } else { - files = [files] + // Files will either be an array of file objects, which we can send directly + // to the create-torrent screen + if (files.length === 0 || typeof files[0] !== 'string') { + state.location.go({ + url: 'create-torrent', + files: files + }) + return } + // ... or it will be an array of mixed file and folder paths. We have to walk + // through all the folders and find the files findFilesRecursive(files, showCreateTorrent) }