Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rwlockfile

Package Overview
Dependencies
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rwlockfile - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

15

lib/rwlockfile.js

@@ -25,3 +25,5 @@ const fs = require('graceful-fs');

let pid = parseInt(file.trim());
return pidActive(pid);
let active = pidActive(pid);
if (!active) debug(`stale pid ${path} ${pid}`);
return active;
} catch (err) {

@@ -34,3 +36,2 @@ if (err.code !== 'ENOENT') throw err;

function unlock(path) {
debug(`unlocking ${path}`);
return new Promise(resolve => rimraf(path, resolve)).then(() => {

@@ -46,3 +47,2 @@ delete locks[path];

function unlockSync(path) {
debug(`unlocking ${path}`);
try {

@@ -57,3 +57,2 @@ rimraf.sync(path);

function lock(p, timeout) {
debug(`locking ${p}`);
let pidPath = path.join(p, 'pid');

@@ -71,2 +70,3 @@ return new Promise((resolve, reject) => {

if (timeout <= 0) throw new Error(`${p} is locked`);
debug(`locking ${p} ${timeout / 100}s...`);
wait().then(() => lock(p, timeout - 100).then(resolve).catch(reject));

@@ -197,3 +197,3 @@ }).catch(reject);

let timeout = options.timeout || 60000;
debug(`write(${path}, timeout=${timeout}, skipOwnPid=${skipOwnPid.toString()})`);
debug(`write ${path}`);
await waitForReaders(path, timeout, skipOwnPid);

@@ -213,3 +213,3 @@ await lock(path + '.writer', timeout);

let timeout = options.timeout || 60000;
debug(`read(${path}, timeout=${timeout})`);
debug(`read ${path}`);
await waitForWriter(path, timeout);

@@ -229,2 +229,3 @@ await lock(path + '.readers.lock', timeout);

async function hasWriter(p) {
debug(`hasWriter ${p}`);
let pid;

@@ -247,3 +248,3 @@ try {

let readers = await getActiveReaders(p, timeout, skipOwnPid);
debug(`hasReaders(${p}): ${readers.length}`);
debug(`hasReaders ${p}: ${readers.length}`);
return readers.length !== 0;

@@ -250,0 +251,0 @@ }

{
"name": "rwlockfile",
"description": "lockfile utility with reader/writers",
"version": "1.4.0",
"version": "1.4.1",
"author": "Jeff Dickey @dickeyxxx",
"bugs": "https://github.com/dickeyxxx/rwlockfile/issues",
"dependencies": {
"debug": "2.x",
"graceful-fs": "4.x",

@@ -38,3 +39,4 @@ "ps-node": "0.x",

"prepare": "npm run clean && npm run build",
"test": "jest && flow && standard"
"test": "jest && flow && standard",
"watch": "nodemon -e js -i lib --exec \"npm run prepare\""
},

@@ -41,0 +43,0 @@ "standard": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc