proper-lockfile
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -104,6 +104,11 @@ 'use strict'; | ||
// Verify if we are within the stale threshold | ||
if (lock.lastUpdate <= Date.now() - options.stale) { | ||
return compromisedLock(file, lock, errcode(lock.updateError || 'Unable to update lock within the stale threshold', 'ECOMPROMISED')); | ||
if (lock.lastUpdate <= Date.now() - options.stale | ||
&& lock.lastUpdate > Date.now() - options.stale * 2) { | ||
return compromisedLock(file, lock, | ||
errcode(lock.updateError || 'Unable to update lock within the stale threshold', 'ECOMPROMISED')); | ||
} | ||
// If the file is older than (stale * 2), we assume the clock is moved manually, | ||
// which we consider a valid case | ||
// If it failed to update the lockfile, keep trying unless | ||
@@ -110,0 +115,0 @@ // the lockfile was deleted! |
{ | ||
"name": "proper-lockfile", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A inter-process and inter-machine lockfile utility that works on a local or network file system.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,2 +12,8 @@ 'use strict'; | ||
function printExcerpt(logs, index) { | ||
logs.slice(Math.max(0, index - 50), index + 50).forEach(function (log, index) { | ||
process.stdout.write((index + 1) + ' ' + log.timestamp + ' ' + log.message + '\n'); | ||
}); | ||
} | ||
function master() { | ||
@@ -67,7 +73,2 @@ var logs = [], | ||
// Print logs | ||
logs.forEach(function (log, index) { | ||
process.stdout.write((index + 1) + ' ' + log.timestamp + ' ' + log.message + '\n'); | ||
}); | ||
// Validate logs | ||
@@ -79,2 +80,4 @@ logs.forEach(function (log, index) { | ||
process.stdout.write('\nInconsistent at line ' + (index + 1) + '\n'); | ||
printExcerpt(logs, index); | ||
process.exit(1); | ||
@@ -88,2 +91,3 @@ } | ||
process.stdout.write('\nInconsistent at line ' + (index + 1) + '\n'); | ||
printExcerpt(logs, index); | ||
process.exit(1); | ||
@@ -90,0 +94,0 @@ } |
52066
1106