-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
I'm able to write to a file despite the library is working. Here is my "locking" code:
const file = './file.txt';
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// === main logic ===
lockfile.lock(file)
.then(async (release) => {
await delay(10000);
return release();
})
.catch((e) => {
console.error(e)
});
It locks the file.txt for 10 seconds, and during this time I shouldn't be able to write the file from other processes(if I understand it correctly), but I can open the file in windows "notepad" and change the text.
Here is the code I run in parallel, and it also does rewrite the file.txt :
(() => {
try {
const fd = fs.openSync('./file.txt', 'a+');
fs.writeFileSync(fd, 'some nasty text')
} catch (e) {
console.error(e);
}
})();
So, what does the lib do?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels