Skip to content

Commit

Permalink
fix: Replace lockfile package
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 8, 2017
1 parent e293efb commit 0d60895
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"debug": "^2.6.8",
"get-port": "^3.1.0",
"glob": "^7.1.2",
"lockfile": "^1.0.3",
"mkdirp": "^0.5.1",
"mongodb-download": "^2.2.3",
"proper-lockfile": "^2.0.1",
"tmp": "^0.0.31",
"uuid": "^3.0.1"
},
Expand Down
18 changes: 11 additions & 7 deletions src/util/MongoBinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MongoDBDownload } from 'mongodb-download';
import glob from 'glob';
import os from 'os';
import path from 'path';
import lockFile from 'proper-lockfile';
import LockFile from 'lockfile';
import mkdirp from 'mkdirp';

export type MongoBinaryCache = {
Expand Down Expand Up @@ -54,14 +54,18 @@ export default class MongoBinary {
});
});

const lockfile = path.resolve(downloadDir, `${version}.lock`);

// wait lock
await new Promise((resolve, reject) => {
lockFile.lock(
downloadDir,
LockFile.lock(
lockfile,
{
stale: 120000,
// try to get lock every second, give up after 3 minutes
retries: { retries: 180, factor: 1, minTimeout: 1000 },
wait: 120000,
pollPeriod: 100,
stale: 110000,
retries: 3,
retryWait: 100,
},
err => {
if (err) reject(err);
Expand All @@ -86,7 +90,7 @@ export default class MongoBinary {
}

// remove lock
lockFile.unlock(downloadDir, err => {
LockFile.unlock(lockfile, err => {
debug(
err
? `MongoBinary: Error when removing download lock ${err}`
Expand Down
11 changes: 4 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,10 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lockfile@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/lockfile/-/lockfile-1.0.3.tgz#2638fc39a0331e9cac1a04b71799931c9c50df79"

lodash._baseassign@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e"
Expand Down Expand Up @@ -3365,13 +3369,6 @@ progress@^1.1.8:
version "1.1.8"
resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"

proper-lockfile@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-2.0.1.tgz#159fb06193d32003f4b3691dd2ec1a634aa80d1d"
dependencies:
graceful-fs "^4.1.2"
retry "^0.10.0"

proto-list@~1.2.1:
version "1.2.4"
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
Expand Down

0 comments on commit 0d60895

Please sign in to comment.