Fix seeding functionality
Fix for small oversight in @dcposch’s recent changes. Broken when adding the distinction between active and inactive torrents. Please code review, @dcposch
This commit is contained in:
@@ -315,14 +315,20 @@ function addTorrent (torrentId) {
|
|||||||
|
|
||||||
var torrent = startTorrenting(torrentId)
|
var torrent = startTorrenting(torrentId)
|
||||||
|
|
||||||
// If torrentId is a torrent file, wait for WebTorrent to finish reading it
|
addTorrentToList(torrent)
|
||||||
if (!torrent.infoHash) torrent.on('infoHash', addTorrentToList)
|
}
|
||||||
else addTorrentToList()
|
|
||||||
|
|
||||||
function addTorrentToList () {
|
function addTorrentToList (torrent) {
|
||||||
if (getTorrentSummary(torrent.infoHash)) {
|
if (getTorrentSummary(torrent.infoHash)) {
|
||||||
return // Skip, torrent is already in state.saved
|
return // Skip, torrent is already in state.saved
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If torrentId is a remote torrent (filesystem path, http url, etc.), wait for
|
||||||
|
// WebTorrent to finish reading it
|
||||||
|
if (torrent.infoHash) onInfoHash()
|
||||||
|
else torrent.on('infoHash', onInfoHash)
|
||||||
|
|
||||||
|
function onInfoHash () {
|
||||||
state.saved.torrents.push({
|
state.saved.torrents.push({
|
||||||
status: 'new',
|
status: 'new',
|
||||||
name: torrent.name,
|
name: torrent.name,
|
||||||
@@ -353,6 +359,7 @@ function stopTorrenting (infoHash) {
|
|||||||
function seed (files) {
|
function seed (files) {
|
||||||
if (files.length === 0) return
|
if (files.length === 0) return
|
||||||
var torrent = state.client.seed(files)
|
var torrent = state.client.seed(files)
|
||||||
|
addTorrentToList(torrent)
|
||||||
addTorrentEvents(torrent)
|
addTorrentEvents(torrent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user