From 607d4fa57ecc1249d2b69d39a266c28a5fa2decd Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Thu, 6 Jul 2017 17:19:29 +0200 Subject: [PATCH] Fixed broken pinneddata.js and added blob data to the stats --- pinneddata.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pinneddata.js b/pinneddata.js index 8dbbc7fec..2ecf8605d 100644 --- a/pinneddata.js +++ b/pinneddata.js @@ -30,7 +30,7 @@ const sizeForHashes = (hashes, dsFileStats) => { let sum = 0; hashes.forEach((h) => { const s = dsFileStats[h]; - if (typeof(s) !== 'number') { + if (typeof(s) !== 'object' || typeof(s.size) !== 'number') { //console.log('missing ' + h + ' ' + typeof(s)); } else { sum += s.size; @@ -62,11 +62,26 @@ nThen((waitFor) => { }); }); }).nThen((waitFor) => { + + Fs.readdir('./blob', waitFor((err, list) => { + if (err) { throw err; } + dirList = list; + })); +}).nThen((waitFor) => { + dirList.forEach((f) => { + sema.take((returnAfter) => { + Fs.readdir('./blob/' + f, waitFor(returnAfter((err, list2) => { + if (err) { throw err; } + list2.forEach((ff) => { fileList.push('./blob/' + f + '/' + ff); }); + }))); + }); + }); +}).nThen((waitFor) => { fileList.forEach((f) => { sema.take((returnAfter) => { Fs.stat(f, waitFor(returnAfter((err, st) => { if (err) { throw err; } - dsFileStats[f.replace(/^.*\/([^\/]*)\.ndjson$/, (all, a) => (a))] = st; + dsFileStats[f.replace(/^.*\/([^\/\.]*)(\.ndjson)?$/, (all, a) => (a))] = st; }))); }); });