Comparing version 0.4.1 to 0.4.2
@@ -9,2 +9,8 @@ var fs = require('fs') | ||
var os = require('os') | ||
var filetime = 'ctime' | ||
if (os.platform() == "win32") { | ||
filetime = 'mtime' | ||
} | ||
var debug | ||
@@ -90,3 +96,3 @@ var util = require('util') | ||
fs.close(fd, function (er) { | ||
var age = Date.now() - st.ctime.getTime() | ||
var age = Date.now() - st[filetime].getTime() | ||
return cb(er, age <= opts.stale) | ||
@@ -124,3 +130,3 @@ }) | ||
} | ||
var age = Date.now() - st.ctime.getTime() | ||
var age = Date.now() - st[filetime].getTime() | ||
return (age <= opts.stale) | ||
@@ -179,3 +185,3 @@ } | ||
var age = Date.now() - st.ctime.getTime() | ||
var age = Date.now() - st[filetime].getTime() | ||
if (age > opts.stale) { | ||
@@ -237,3 +243,3 @@ debug('lock stale', path, opts_) | ||
var st = fs.statSync(path) | ||
var ct = st.ctime.getTime() | ||
var ct = st[filetime].getTime() | ||
if (!(ct % 1000) && (opts.stale % 1000)) { | ||
@@ -240,0 +246,0 @@ // probably don't have subsecond resolution. |
{ | ||
"name": "lockfile", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"main": "lockfile.js", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -16,2 +16,3 @@ var test = require('tap').test | ||
try { lockFile.unlockSync('stale-wait-lock') } catch (er) {} | ||
try { lockFile.unlockSync('stale-windows-lock') } catch (er) {} | ||
t.end() | ||
@@ -253,2 +254,26 @@ }) | ||
test('stale windows file tunneling test', function (t) { | ||
// for windows only | ||
// nt file system tunneling feature will make file creation time not updated | ||
var opts = { stale: 1000 } | ||
lockFile.lockSync('stale-windows-lock') | ||
setTimeout(next, 2000) | ||
function next () { | ||
var locked | ||
lockFile.unlockSync('stale-windows-lock') | ||
lockFile.lockSync('stale-windows-lock', opts) | ||
locked = lockFile.checkSync('stale-windows-lock', opts) | ||
t.ok(locked, "should be locked and not stale") | ||
lockFile.lock('stale-windows-lock', opts, function (er) { | ||
if (!er) | ||
t.fail('got second lock? impossible, windows file tunneling problem!') | ||
else | ||
t.pass('second lock failed, windows file tunneling problem fixed') | ||
t.end() | ||
}) | ||
} | ||
}) | ||
test('cleanup', function (t) { | ||
@@ -263,4 +288,5 @@ try { lockFile.unlockSync('basic-lock') } catch (er) {} | ||
try { lockFile.unlockSync('stale-wait-lock') } catch (er) {} | ||
try { lockFile.unlockSync('stale-windows-lock') } catch (er) {} | ||
t.end() | ||
}) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19701
504