var getDeletedPads = function (Env, channels, cb) { if (!Array.isArray(channels)) { return cb('INVALID_LIST'); } var L = channels.length; var sem = Saferphore.create(10); var absentees = []; var job = function (channel, wait) { return function (give) { getFileSize(Env, channel, wait(give(function (e, size) { if (e) { return; } if (size === 0) { absentees.push(channel); } }))); }; }; nThen(function (w) { for (var i = 0; i < L; i++) { sem.take(job(channels[i], w)); } }).nThen(function () { cb(void 0, absentees); }); };
/* jshint esversion: 6, node: true */ const Fs = require('fs'); const Path = require("path"); const Semaphore = require('saferphore'); const Once = require("../lib/once"); const nThen = require('nthen'); const Pins = require("../lib/pins"); const sema = Semaphore.create(20); let dirList; const fileList = []; const pinned = {}; module.exports.load = function (cb, config) { var pinPath = config.pinPath || './pins'; var done = Once(cb); nThen((waitFor) => { // recurse over the configured pinPath, or the default Fs.readdir(pinPath, waitFor((err, list) => { if (err) { if (err.code === 'ENOENT') { dirList = []; return; // this ends up calling back with an empty object } waitFor.abort(); return void done(err); } dirList = list; }));