diff --git a/routes/cdn.js b/routes/cdn.js index ad30567..7a6f5cf 100644 --- a/routes/cdn.js +++ b/routes/cdn.js @@ -39,7 +39,15 @@ function tar_index_files(input){ var extract = tar.extract({allowUnknownFormat: true}) .on('entry', process_entry) .on('finish', finish_stream) - .on('error', reject); + .on('error', function(err){ + if (err.message.includes('Unexpected end') && files.length > 0){ + finish_stream(); //workaround tar-stream bug for custom webr 0.4.2 tar headers + } else { + reject(err); + } + }); + + input.pipe(gunzip()).pipe(extract); }); } @@ -66,7 +74,8 @@ send_from_bucket = function(hash, file, res){ if(file === `${name}.index` && name.endsWith('gz')){ return tar_index_files(stream_file(pkg)).then(function(index){ index.files.forEach(function(entry){ - entry.filename = entry.filename.match(/\/.*/)[0]; //strip pkg root dir + var newname = entry.filename.match(/\/.*/); //strip pkg root dir + entry.filename = newname ? newname[0] : "unknown"; }); index.gzip = true; res.send(index);