diff --git a/lib/db/json.js b/lib/db/json.js index d26202992c7689a4ee84883e2f7aa5a1daad5bb8..76e23bab45753070893eeafa83393d741c80ed89 100644 --- a/lib/db/json.js +++ b/lib/db/json.js @@ -106,12 +106,13 @@ exports.open = function(cfg, cb) { }; exports.closeAndRemove = function(cb) { - flush(); fs.unlink(dbPath, function(err) { cb(err === null ? undefined : err); }); }; exports.close = function(cb) { - flush(); + // don't flush database here to disk, the database is flushed synchronously when + // written - If we were to flush here we could overwrite changes made by + // another process - see issue #557 setTimeout(function() { cb(undefined) }, 0); };