Fixed race condtion causing server to occasionally fail to start up
This commit is contained in:
parent
ff0e4bfe86
commit
fe0030a0d6
@ -35,11 +35,16 @@ const hashesFromPinFile = (pinFile, fileName) => {
|
|||||||
module.exports.load = function (cb) {
|
module.exports.load = function (cb) {
|
||||||
nThen((waitFor) => {
|
nThen((waitFor) => {
|
||||||
Fs.readdir('./pins', waitFor((err, list) => {
|
Fs.readdir('./pins', waitFor((err, list) => {
|
||||||
if (err) { throw err; }
|
if (err) {
|
||||||
|
if (err.code === 'ENOENT') {
|
||||||
|
dirList = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
dirList = list;
|
dirList = list;
|
||||||
}));
|
}));
|
||||||
}).nThen((waitFor) => {
|
}).nThen((waitFor) => {
|
||||||
fileList.splice(0, fileList.length);
|
|
||||||
dirList.forEach((f) => {
|
dirList.forEach((f) => {
|
||||||
sema.take((returnAfter) => {
|
sema.take((returnAfter) => {
|
||||||
Fs.readdir('./pins/' + f, waitFor(returnAfter((err, list2) => {
|
Fs.readdir('./pins/' + f, waitFor(returnAfter((err, list2) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user