Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements BEP53 to allow file selection using &so in magnetURIs #1396

Merged
merged 2 commits into from May 18, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

Makes things clearer and removes redundant / unused code.

  • Loading branch information
SilentBot1 committed May 18, 2018
commit 113363223b4e77d766a5f917b649c7435974c56a
@@ -505,14 +505,12 @@ Torrent.prototype._onMetadata = function (metadata) {
return new File(self, file)
})

// Only select specified files (BEP53)
// Select only specified files (BEP53) http://www.bittorrent.org/beps/bep_0053.html
if (self.so) {
var specificFiles = parseRange.parse(self.so)
// https://github.com/webtorrent/webtorrent/issues/164
self.deselect(0, self.pieces.length - 1, false)
var selectOnlyFiles = parseRange.parse(self.so)

self.files.forEach(function (v, i) {
specificFiles.indexOf(i) === -1 ? self.files[i].deselect() : self.files[i].select(true)
if (selectOnlyFiles.includes(i)) self.files[i].select(true)
})
} else {
// start off selecting the entire torrent with low priority
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.