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

strings not supported as input to `client.seed` in node #197

Closed
bengl opened this issue Dec 2, 2014 · 6 comments
Closed

strings not supported as input to `client.seed` in node #197

bengl opened this issue Dec 2, 2014 · 6 comments

Comments

@bengl
Copy link

@bengl bengl commented Dec 2, 2014

This might actually be related to #183, but it's a different error, so I think it warrants a separate issue.

From my quick testing, it seems that the string inputs don't work on client.seed.

Example:

// basicTorrent.js
var WebTorrent = require('webtorrent');

var client = new WebTorrent();

// seed a new torrent of this file
client.seed(__filename, function (torrent) {
    console.log(torrent);
});

The result is this:

~/testing $ node basicTorrent.js 

/home/bengl/testing/node_modules/webtorrent/index.js:207
  var streams = input.map(function (item) {
                      ^
TypeError: Object /home/bengl/testing/basicTorrent.js has no method 'map'
    at WebTorrent.seed (/home/bengl/testing/node_modules/webtorrent/index.js:207:23)
    at Object.<anonymous> (/home/bengl/testing/basicTorrent.js:5:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

So it looks like it expects an array. No prob, wrapped __filename up in an array before passing it into client.seed. The result:

~/testing $ node basicTorrent.js 

/home/bengl/testing/node_modules/webtorrent/index.js:213
    } else throw new Error('unsupported input type to `seed`')
                 ^
Error: unsupported input type to `seed`
    at /home/bengl/testing/node_modules/webtorrent/index.js:213:18
    at Array.map (native)
    at WebTorrent.seed (/home/bengl/testing/node_modules/webtorrent/index.js:207:23)
    at Object.<anonymous> (/home/bengl/testing/basicTorrent.js:5:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16

It really looks like file or path strings aren't actually supported. I also tried on __dirname with similar results. Also with arbitrary files and paths.

Here's the version info:

~/testing/node_modules/webtorrent $ npm version
{ http_parser: '1.0',
  node: '0.10.33',
  v8: '3.14.5.9',
  ares: '1.9.0-DEV',
  uv: '0.10.29',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1j',
  npm: '2.1.9',
  webtorrent: '0.14.0' }
@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Dec 4, 2014

Correct, it doesn't seem to be implemented as of yet. See here: https://github.com/feross/webtorrent/blob/master/index.js#L199

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 5, 2014

No, filenames should be supported. This is a regression.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 5, 2014

Scratch that. Filenames are supported for create-torrent but not in webrtorrent yet. Sorry about that. Will add asap. PR also welcome!

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 16, 2014

This is a first pass at supporting seeding files (specified as string file paths) for client.seed: #209

Still need a separate PR to support seeding folders.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 17, 2014

I just changed create-torrent to expose it's input parsing logic since the code is basically exactly the same as client.seed and then we'll get folders for free. See: webtorrent/create-torrent@e370deb

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 29, 2014

This was fixed and released as 0.17.0 a few days ago.

@feross feross closed this Dec 29, 2014
@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.