diff --git a/docs/api.md b/docs/api.md index 3a06171f..94cb519e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -63,6 +63,13 @@ If you want access to the torrent object immediately in order to listen to event metadata is fetched from the network, then use the return value of `client.add`. If you just want the file data, then use `ontorrent` or the 'torrent' event. +If you provide `opts.store`, it will be called as +`opts.store(chunkLength, storeOpts)` with: + +* `storeOpts.length` - size of all the files in the torrent +* `storeOpts.files` - an array of torrent file objects +* `storeOpts.torrent` - the torrent instance being stored + ## `client.seed(input, [opts], [function onseed (torrent) {}])` Start seeding a new torrent. diff --git a/lib/torrent.js b/lib/torrent.js index 88e8799c..4ccd26e5 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -344,6 +344,7 @@ Torrent.prototype._onMetadata = function (metadata) { self.store = new ImmediateChunkStore( new self._store(self.pieceLength, { + torrent: self, files: self.files.map(function (file) { return { path: path.join(self.path, file.path),