Skip to content

Commit

Permalink
fix: 3 minutes try to get lock when downloading binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 7, 2017
1 parent fca0f0c commit f931025
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions src/util/MongoBinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,40 @@ export default class MongoBinary {
});
});
this.cache[version] = new Promise((resolve, reject) => {
lockFile.lock(downloadDir, { stale: 120000, retries: 3 }, (err, releaseLock) => {
if (err) {
reject(err);
return;
}
lockFile.lock(
downloadDir,
{
stale: 120000,
// try to get lock every second, give up after 3 minutes
retries: { retries: 180, factor: 1, minTimeout: 1000 },
},
(err, releaseLock) => {
if (err) {
reject(err);
return;
}

const downloader = new MongoDBDownload({
downloadDir,
platform,
arch,
version,
http,
});
const downloader = new MongoDBDownload({
downloadDir,
platform,
arch,
version,
http,
});

if (opts.debug) {
downloader.debug = console.log.bind(null);
}
if (opts.debug) {
downloader.debug = console.log.bind(null);
}

downloader
.downloadAndExtract()
.then(releaseDir => {
releaseLock();
resolve(this.findBinPath(releaseDir));
})
.catch(e => reject(e));
});
downloader
.downloadAndExtract()
.then(releaseDir => {
releaseLock();
resolve(this.findBinPath(releaseDir));
})
.catch(e => reject(e));
}
);
});
}
return this.cache[version];
Expand Down

0 comments on commit f931025

Please sign in to comment.