hex7c0 / mongodb-restore

restore data from mongodb-backup for Nodejs
https://github.com/hex7c0/mongodb-restore
Apache License 2.0
53 stars 21 forks source link

BSON-Parser throws when collection contains no documents #14

Open cdxOo opened 7 years ago

cdxOo commented 7 years ago

When trying to restore a dump that contains a collection that has no documents in it, the BSON parser throws with 'Error: corrupt bson message'. The bson file representing the empty collection is 0 bytes and therefor invalid bson.

In fromJson() just test for data.length before deserializing and pushing to docsBulk to fix this