Skip to content

Commit ede5dd6

Browse files
hugomrdiasjacobheun
authored andcommittedNov 28, 2018
fix: fix staleness check (#182)
* fix: fix staleness check * fix: extract stale value to const
1 parent 9041f4a commit ede5dd6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎src/lock.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ const debug = require('debug')
55
const { lock } = require('proper-lockfile')
66

77
const log = debug('repo:lock')
8-
98
const lockFile = 'repo.lock'
109

10+
/**
11+
* Duration in milliseconds in which the lock is considered stale
12+
* @see https://github.com/moxystudio/node-proper-lockfile#lockfile-options
13+
* The default value of 10000 was too low for ipfs and sometimes `proper-lockfile`
14+
* would throw an exception because it couldn't update the lock file mtime within
15+
* the 10s threshold. @see https://github.com/ipfs/js-ipfs-repo/pull/182
16+
* Increasing to 20s is a temporary fix a permanent fix should be implemented in
17+
* the future.
18+
*/
19+
const STALE_TIME = 20000
20+
1121
/**
1222
* Lock the repo in the given dir.
1323
*
@@ -19,7 +29,7 @@ exports.lock = (dir, callback) => {
1929
const file = path.join(dir, lockFile)
2030
log('locking %s', file)
2131

22-
lock(dir, {lockfilePath: file})
32+
lock(dir, {lockfilePath: file, stale: STALE_TIME})
2333
.then(release => {
2434
callback(null, {close: (cb) => {
2535
release()

0 commit comments

Comments
 (0)
Please sign in to comment.