From 7d196763f8f6c2912336e0c2e5c877eb0016c83c Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Sat, 1 Dec 2018 23:59:36 -0500 Subject: [PATCH] Update docs, fix test failure --- README.md | 17 ++++++++++++++++- tests/spec/fs.fsync.spec.js | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 925a53e..a0f003f 100644 --- a/README.md +++ b/README.md @@ -914,7 +914,22 @@ fs.open('/myfile.txt', function(err, fd) { #### fs.fsync(fd, callback) -NOTE: Not yet implemented, see https://github.com/filerjs/filer/issues/87 +Synchronize the data and metadata for the file referred to by `fd` to disk. +Asynchronous [fsync(2)](http://man7.org/linux/man-pages/man2/fsync.2.html). +The callback gets `(error)`. + +```js +fs.open('/myfile', 'r', function(error, fd) { + if(err) throw err; + + // Use fd, then sync + + fs.fsync(fd, function(error) { + if(err) throw err; + fs.close(fd, done); + }); +}); +``` #### fs.write(fd, buffer, offset, length, position, callback) diff --git a/tests/spec/fs.fsync.spec.js b/tests/spec/fs.fsync.spec.js index fcedaab..6c21877 100644 --- a/tests/spec/fs.fsync.spec.js +++ b/tests/spec/fs.fsync.spec.js @@ -38,8 +38,8 @@ describe('fs.fsync', function() { if(error) throw error; fs.fsync(fd, function(error) { - expect(error).to.not.exist; - fs.close(done); + expect(error).not.to.exist; + fs.close(fd, done); }); }); });