diff options
author | Julen Garcia Leunda <hicom150@gmail.com> | 2020-08-15 23:39:15 +0300 |
---|---|---|
committer | Julen Garcia Leunda <hicom150@gmail.com> | 2020-11-04 00:10:35 +0300 |
commit | 559544469f9a8969ad37675cc617cd94bebb2797 (patch) | |
tree | 6b281959ae980be4486b59012ff10b3eb9a622cb /lib | |
parent | cb22ffe697a128030fa06b08b93d7d0106065637 (diff) |
Fix BEP53 implementation
Diffstat (limited to 'lib')
-rw-r--r-- | lib/torrent.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index 077edcb..12ec6ee 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -25,7 +25,6 @@ const speedometer = require('speedometer') const utMetadata = require('ut_metadata') const utPex = require('ut_pex') // browser exclude const utp = require('utp-native') // browser exclude -const parseRange = require('parse-numeric-range') const File = require('./file') const Peer = require('./peer') @@ -486,10 +485,12 @@ class Torrent extends EventEmitter { // Select only specified files (BEP53) http://www.bittorrent.org/beps/bep_0053.html if (this.so) { - const selectOnlyFiles = parseRange(this.so) - this.files.forEach((v, i) => { - if (selectOnlyFiles.includes(i)) this.files[i].select(true) + if (this.so.includes(i)) { + this.files[i].select() + } else { + this.files[i].deselect() + } }) } else { // start off selecting the entire torrent with low priority |