fcf.NLock.unlockFile() function
[SERVER ONLY]
fcf.NLock.unlockFile (number a_lock, function a_cb)
Package: fcf-framework-lock
File: fcf-framework-lock:index.js
Available from version: 1.0.0
Removes a locks on a file
Arguments
- The lock handle
- The function of processing the result of the function execution
Function signature: a_cb(
-
Error |undefined a_error - Error object
Example: Function application
const libLock = require("fcf-framework-lock");
function action(a_name) {
console.log(`Action ${a_name}: Start locking file...`);
libLock .lockFile ("index.js", (a_error, a_lock)=>{
if (a_error){
console.log("Error lock on file");
process.exit(1);
}
console.log(`Action ${a_name}: We do some action`);
setTimeout(()=>{
console.log(`Action ${a_name}: Removing a lock from a file`);
libLock .unlockFile (a_lock, (a_error)=>{
if (a_error){
console.log("Error unlock on file");
process.exit(1);
}
});
}, 1000);
})
}
action("1");
action("2");
Output:
Action 1: Start locking file...
Action 2: Start locking file...
Action 1: We do some action
Action 1: Removing a lock from a file
Action 2: We do some action
Action 2: Removing a lock from a file