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

File overriden when seeding multiple torrents #416

Closed
valeriangalliat opened this issue Sep 2, 2015 · 2 comments
Closed

File overriden when seeding multiple torrents #416

valeriangalliat opened this issue Sep 2, 2015 · 2 comments

Comments

@valeriangalliat
Copy link
Contributor

@valeriangalliat valeriangalliat commented Sep 2, 2015

Hi,

I'm running the following code to seed files with WebTorrent:

var WebTorrent = require('webtorrent')

var client = new WebTorrent({ dht: false })

var opts = {
  announce: [ 'udp://localhost:8000' ]
}

client.seed('foo.png', opts, function (torrent) {
  console.log('seeding:', torrent.magnetURI)
})

client.seed('test.webm', opts, function (torrent) {
  console.log('seeding:', torrent.magnetURI)
})

But the magnet URI file is foo.png for both torrents, and surprisingly, foo.png is overriden with test.webm content on the filesystem!

Here's the DEBUG=webtorrent* output:

DEBUG=webtorrent* node seed.js  
  webtorrent new webtorrent (peerId 2d5757303036302d313237663861636638323739, nodeId d67a4f91af4c4c97bd21d60922c5cb8b77530f15) +0ms
  webtorrent seed +4ms
  webtorrent add +2ms
  webtorrent:torrent new torrent +1ms
  webtorrent seed +5ms
  webtorrent add +1ms
  webtorrent:torrent new torrent +1ms
  webtorrent:torrent got metadata +59ms
  webtorrent:torrent verifying existing torrent data +3ms
  webtorrent:torrent piece verified 0 +10ms
  webtorrent:torrent piece verified 1 +0ms
  webtorrent:torrent piece verified 2 +0ms
  webtorrent:torrent piece verified 3 +0ms
  webtorrent:torrent piece verified 5 +0ms
  webtorrent:torrent piece verified 4 +1ms
  webtorrent:torrent piece verified 7 +0ms
  webtorrent:torrent piece verified 6 +0ms
  webtorrent:torrent piece verified 8 +0ms
  webtorrent:torrent piece verified 9 +0ms
  webtorrent:torrent piece verified 10 +0ms
  webtorrent:torrent done verifying +0ms
  webtorrent:torrent on store +0ms
  webtorrent:torrent select 0-10 (priority 0) +0ms
  webtorrent on torrent 1ffe673ef660a2bf354dee818253e2c4494604aa +1ms
  webtorrent:torrent file done: foo.png +7ms
  webtorrent:torrent torrent done: 1ffe673ef660a2bf354dee818253e2c4494604aa +0ms
  webtorrent:torrent torrent done: 1ffe673ef660a2bf354dee818253e2c4494604aa +43ms
  webtorrent on seed +1ms
  webtorrent:torrent got metadata +78ms
  webtorrent:torrent verifying existing torrent data +2ms
  webtorrent:torrent piece invalid 0 +10ms
  webtorrent:torrent piece invalid 1 +1ms
  webtorrent:torrent piece invalid 2 +0ms
  webtorrent:torrent piece invalid 3 +0ms
  webtorrent:torrent piece invalid 4 +0ms
  webtorrent:torrent piece invalid 6 +0ms
  webtorrent:torrent piece invalid 5 +1ms
  webtorrent:torrent piece invalid 8 +0ms
  webtorrent:torrent piece invalid 7 +0ms
  webtorrent:torrent piece invalid 9 +0ms
  webtorrent:torrent done verifying +4ms
  webtorrent:torrent on store +0ms
  webtorrent:torrent select 0-133 (priority 0) +0ms
  webtorrent on torrent 299c990a67b5bc3551afd75b178e7b610af89e7c +1ms
  webtorrent:torrent file done: foo.png +40ms
  webtorrent:torrent torrent done: 299c990a67b5bc3551afd75b178e7b610af89e7c +0ms
  webtorrent on seed +1ms

I'm still trying to find out why this bug is happening...

@valeriangalliat

This comment has been minimized.

Copy link
Contributor Author

@valeriangalliat valeriangalliat commented Sep 2, 2015

Okay I got it!

It's because I'm passing the same opts object for both torrents, and WebTorrent is mutating this object in both torrents... so the first one sets opts.name as foo.png and opts.name is not computed for the second file.

Do you think opts should be cloned before being mutated inside WebTorrent?

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Sep 2, 2015

Yes, it should definitely be cloned before being mutated. This is a bug.

On Wed, Sep 2, 2015 at 1:15 PM Valérian Galliat notifications@github.com
wrote:

Okay I got it!

It's because I'm passing the same opts object for both torrents, and
WebTorrent is mutating this object in both torrents... so the first one
sets opts.name as foo.png and opts.name is not computed for the second
file.

Do you think opts should be cloned before being mutated inside WebTorrent?


Reply to this email directly or view it on GitHub
#416 (comment).

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.