From 0afec083dfe3291fd9bbd57d7565469bb7ebb25b Mon Sep 17 00:00:00 2001 From: DC Date: Mon, 21 Mar 2016 04:38:09 -0700 Subject: [PATCH] Store path in each torrentSummary. Fixes #73 --- renderer/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/renderer/index.js b/renderer/index.js index 582322c2..6ba77a28 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -427,17 +427,17 @@ function addTorrentToList (torrent) { // Starts downloading and/or seeding a given torrentSummary. Returns WebTorrent object function startTorrentingSummary (torrentSummary) { var s = torrentSummary - if (s.torrentPath) return startTorrentingID(s.torrentPath) - else if (s.magnetURI) return startTorrentingID(s.magnetURI) - else return startTorrentingID(s.infoHash) + if (s.torrentPath) return startTorrentingID(s.torrentPath, s.path) + else if (s.magnetURI) return startTorrentingID(s.magnetURI, s.path) + else return startTorrentingID(s.infoHash, s.path) } // Starts a given TorrentID, which can be an infohash, magnet URI, etc. Returns WebTorrent object // See https://github.com/feross/webtorrent/blob/master/docs/api.md#clientaddtorrentid-opts-function-ontorrent-torrent- -function startTorrentingID (torrentID) { +function startTorrentingID (torrentID, path) { console.log('Starting torrent ' + torrentID) var torrent = state.client.add(torrentID, { - path: state.saved.downloadPath // Use downloads folder + path: path || state.saved.downloadPath // Use downloads folder }) addTorrentEvents(torrent) return torrent @@ -469,6 +469,7 @@ function addTorrentEvents (torrent) { torrentSummary.ready = true torrentSummary.name = torrentSummary.displayName || torrent.name torrentSummary.infoHash = torrent.infoHash + torrentSummary.path = torrent.path // Summarize torrent files torrentSummary.files = torrent.files.map(summarizeFileInTorrent)