Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions bin/muntar
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var manta = require('../lib');

var http = require('http');
var https = require('https');
var tar = require('tar');
var tar = require('tar-stream');

///--- Globals

Expand Down Expand Up @@ -188,7 +188,7 @@ function worker(client, tarball, callback) {
var entry = 0;
var inflight = 1;
var stream = fs.createReadStream(tarball.file);
var pipe = stream.pipe(tar.Parse());
var pipe = stream.pipe(tar.extract());
var options = tarball.options;

callback = once(callback);
Expand Down Expand Up @@ -228,16 +228,21 @@ function worker(client, tarball, callback) {

LOG.debug({ err: err, num: tarball.retry[_entry] },
'put to ' + path + ' failed; retrying');
e.resume();
}

cb();
});
}

pipe.once('end', cb);
pipe.on('entry', function (e) {
if (e.props.size === 0)
pipe.on('entry', function (header, e, next) {
e.on('end', function () {
next();
});

e.resume();

if (header.size === 0)
return;

if (entry++ < tarball.next) {
Expand All @@ -247,17 +252,15 @@ function worker(client, tarball, callback) {
tarball.next = entry;
}

e.pause();

var headers = options.headers || {};
if (options['role-tag'])
headers['role-tag'] = options['role-tag'].join(',');

var p = options.path + '/' + e.props.path;
var p = options.path + '/' + header.name;
var o = {
copies: options.copies,
headers: headers,
size: e.props.size
size: header.size
};

inflight++;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"restify-clients": "~1.4.1",
"showdown": "~1.4.2",
"smartdc-auth": "^2.4.1",
"tar": "~2.2.1",
"tar-stream": "~1.5.2",
"uuid": "~2.0.2",
"vasync": "^1.6.4",
"verror": "^1.6.1",
Expand Down