baudehlo / node-fs-ext

Extras missing from node's fs module
MIT License
101 stars 45 forks source link

record-level locking... #35

Open tracker1 opened 9 years ago

tracker1 commented 9 years ago

It would be nice if you can do a record level lock for read/write...

fs.flock(fd, 'sh', function(err){
  fs.flockRead(bytesToRead, function(err, buffer){
    //buffer should be the bytes read after an exclusive lock of that record
    // offset at the current position, for the length of the bytes requested to read.
  });
  fs.flockWrite(buffer, function(err){})
});
sam-github commented 5 years ago

flock doesn't support record level locking: https://linux.die.net/man/2/flock

baudehlo commented 5 years ago

I think it's only possible on Windows (not sure if there's mechanisms to do this on Unix-like OS's). It seems like a terribly fragile piece of technology to use, and must be NTFS only.

On Wed, Feb 6, 2019 at 12:59 PM Sam Roberts notifications@github.com wrote:

flock doesn't support record level locking: https://linux.die.net/man/2/flock

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/baudehlo/node-fs-ext/issues/35#issuecomment-461122578, or mute the thread https://github.com/notifications/unsubscribe-auth/AAobYyWdOmics4V9synZmWeOce1gTxToks5vKxflgaJpZM4CxEIX .

sam-github commented 5 years ago

Unixen have byte-range locking: