fent/node-torrent

Problem with single file torrents

zumoshi opened this issue · 1 comments

running the following code

var nt = require('nt');
nt.read('./tmp/a.torrent', function(err, torrent) {
  if (err) throw err;
});

and a.torrent is any torrent with only one file
for example http://torrents.thepiratebay.sx/5656774/data.ini.5656774.TPB.torrent

i get the following:

C:\w\torread.js:4
  if (err) throw err;
                 ^
TypeError: Cannot read property 'length' of undefined
    at C:\w\zbigO\torread.js:6:48
    at Object.exports.validate (C:\w\node_modules\nt\lib\schema.js:212
    at ReadStream.<anonymous> (C:\w\node_modules\nt\lib\read.js:93:14)
    at ReadStream.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:883:14
    at process._tickCallback (node.js:415:13)

apparently torrents with only one file does not have files array in them


Update: my bad , error was somewhere in my own code , i removed try catch from the read.js on callback and trace showed the real line causing the error .
but i also tweaked a few things in the code while looking for the problem . one thing that you might want to change is to allow files with length 0 , i have a 15GB torrent that has a file with length 0 and your module crashes while parsing it

fent commented

Ok. Good to know about that length 0 error. I'm planning on eventually redesigning the entirety of the method that I'm using the hash files, so I'll fix that then.