Skip to content

Commit

Permalink
deserialize stream should always return info obj
Browse files Browse the repository at this point in the history
  • Loading branch information
rclark committed Oct 22, 2014
1 parent fcb6963 commit f2a1294
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/stream-deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Deserialize.prototype.deserialize = function(serializedObj) {

if (this._job) {
var x = deserialize(serializedObj, 'x');
if (x % this._job.total !== this._job.num)
// undefined x means this is an Info object that should be read with any job
if (x !== undefined && x % this._job.total !== this._job.num)
return;
}

Expand Down
5 changes: 5 additions & 0 deletions test/stream-deserialize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ test('deserialize: split into jobs', function(t) {

function runJob(total, num, done) {
var tileCount = 0;
var gotInfo = false;
fs.createReadStream(path.join(__dirname, 'fixtures', 'plain_1.serialtiles'))
.pipe(tilelive.deserialize({ job: { total: total, num: num } }))
.on('error', function(err) {
Expand All @@ -231,9 +232,13 @@ test('deserialize: split into jobs', function(t) {
tileCount++;
}
})
.on('info', function(info) {
gotInfo = true;
})
.on('finish', function() {
tilesPerJob.push(tileCount);
if (num === total - 1) {
t.ok(gotInfo, 'got info object');
t.equal(results.length, 285, 'correct number of tiles across ' + total + ' jobs');
var tiles = results.reduce(function(memo, tile) {
if (memo[tile]) memo[tile]++;
Expand Down

0 comments on commit f2a1294

Please sign in to comment.