nedb
nedb copied to clipboard
No corruption alert for one line corrupted .db file on Windows with corruptAlertThreshold=0%
On Windows:
- Datastore configured with corruptAlertThreshold=0
- replace any db file content with one line without enter (e.g. "a")
- start the app
- notice that "a" is removed and file index is recreated
Expected: DB corruption alert to be reported, since threshold is set to 0% and file content is in a bad format.
Problem source: There is an assumption that a new line always is present: https://github.com/louischatriot/nedb/blob/aa3302e5dcefa471431901a8f3fe63e532a5a7b2/lib/persistence.js#L216
Also when data.length > 0
while $$indexCreated
entry is missing, this can be another sign of a corrupted DB file for a 0% threshold.