Merge pull request #510 from feross/dc/fix

Allow seeding torrents that contain subtitles
This commit is contained in:
Feross Aboukhadijeh
2016-05-13 17:16:16 -07:00

View File

@@ -539,15 +539,23 @@ function saveState () {
function onOpen (files) { function onOpen (files) {
if (!Array.isArray(files)) files = [ files ] if (!Array.isArray(files)) files = [ files ]
// .torrent file = start downloading the torrent // In the player, the only drag-drop function is adding subtitles
files.filter(isTorrent).forEach(addTorrent) var isInPlayer = state.location.current().url === 'player'
if (isInPlayer) {
return files.filter(isSubtitle).forEach(addSubtitle)
}
// subtitle file // Otherwise, you can only drag-drop onto the home screen
files.filter(isSubtitle).forEach(addSubtitle) var isHome = state.location.current().url === 'home' && !state.modal
if (isHome) {
// everything else = seed these files if (files.every(isTorrent)) {
var rest = files.filter(not(isTorrent)).filter(not(isSubtitle)) // All .torrent files? Start downloading
if (rest.length > 0) showCreateTorrent(rest) files.forEach(addTorrent)
} else {
// Show the Create Torrent screen. Let's seed those files.
showCreateTorrent(files)
}
}
} }
function isTorrent (file) { function isTorrent (file) {
@@ -563,12 +571,6 @@ function isSubtitle (file) {
return ext === '.srt' || ext === '.vtt' return ext === '.srt' || ext === '.vtt'
} }
function not (test) {
return function (...args) {
return !test(...args)
}
}
// Gets a torrent summary {name, infoHash, status} from state.saved.torrents // Gets a torrent summary {name, infoHash, status} from state.saved.torrents
// Returns undefined if we don't know that infoHash // Returns undefined if we don't know that infoHash
function getTorrentSummary (torrentKey) { function getTorrentSummary (torrentKey) {