diff --git a/lib/persistence.js b/lib/persistence.js index 50a77d3..38578b9 100755 --- a/lib/persistence.js +++ b/lib/persistence.js @@ -214,18 +214,16 @@ class Persistence { lineStream.on('end', () => { // A bit lenient on corruption + let err = null if (length > 0 && corruptItems / length > this.corruptAlertThreshold) { - const corruptPercent = Math.floor(100 * this.corruptAlertThreshold) - const err = new Error(`More than ${corruptPercent}% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss`) - cb(err, null) - return + err = new Error(`More than ${Math.floor(100 * this.corruptAlertThreshold)}% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss`) } Object.keys(dataById).forEach(function (k) { tdata.push(dataById[k]) }) - cb(null, { data: tdata, indexes: indexes }) + cb(err, { data: tdata, indexes: indexes }) }) lineStream.on('error', function (err) {