newbie node here. i'm trying download .tar.xz
file , extract directory via code shown below:
var request = require('request'); var tar = require('tar'); var xz = require('xz'); function downloadraw(url, callback) { return request({ encoding: null, url: url }, callback); } function extracttodirectory(url, directory, callback) { return downloadraw(url) .pipe(new xz.decompressor()) .pipe(tar.extract(directory)) .on('finish', callback); }
for reason, 'finish'
event on tar stream not seem firing, after finishes extracting contents of archive. tar library that's maintained npm themselves, assume i'm making kind of mistake here. anyway, why happening , can fix it?
i see downloadraw takes callback, never pass one, , pass undefined value request function.
if want use streaming api don't pass callback either of functions.
in fact why bother raw function @ all. why not do:
return request(url) .pipe(newxz.decompressor()) .pipe(tar.extract(directory)) .on('finish', callback);
Comments
Post a Comment