From 94cac41acb0374c969c05bc61cc4fc90ece58426 Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Tue, 24 Nov 2015 13:56:16 +0100 Subject: [PATCH] Fix for windows --- lib/storage.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/storage.js b/lib/storage.js index 002d9c9..24f3455 100755 --- a/lib/storage.js +++ b/lib/storage.js @@ -51,6 +51,10 @@ storage.flushToStorage = function (options, callback) { flags = options.isDir ? 'r' : 'r+'; } + // Windows can't fsync (FlushFileBuffers) directories. We can live with this as it cannot cause 100% dataloss + // except in the very rare event of the first time database is loaded and a crash happens + if (flags === 'r' && (process.platform === 'win32' || process.platform === 'win64')) { return callback(null); } + fs.open(filename, flags, function (err, fd) { if (err) { return callback(err); } fs.fsync(fd, function (errFS) {