diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index 13d6a8c36..7b4334c24 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -2,11 +2,23 @@ const nThen = require("nthen"); const getFolderSize = require("get-folder-size"); const Util = require("../common-util"); +const Ulimit = require("ulimit"); var Fs = require("fs"); var Admin = module.exports; +var getFileDescriptorCount = function (Env, server, cb) { + Fs.readdir('/proc/self/fd', function(err, list) { + if (err) { return void cb(err); } + cb(void 0, list.length); + }); +}; + +var getFileDescriptorLimit = function (env, server, cb) { + Ulimit(cb); +}; + var getActiveSessions = function (Env, Server, cb) { var stats = Server.getSessionStats(); cb(void 0, [ @@ -105,6 +117,8 @@ var commands = { DISK_USAGE: getDiskUsage, FLUSH_CACHE: flushCache, SHUTDOWN: shutdown, + GET_FILE_DESCRIPTOR_COUNT: getFileDescriptorCount, + GET_FILE_DESCRIPTOR_LIMIT: getFileDescriptorLimit, }; Admin.command = function (Env, safeKey, data, _cb, Server) { diff --git a/lib/commands/pin-rpc.js b/lib/commands/pin-rpc.js index 2888f1e61..c15d64e30 100644 --- a/lib/commands/pin-rpc.js +++ b/lib/commands/pin-rpc.js @@ -546,6 +546,8 @@ const deferResponse = function (Env, channel, cb) { }; Pinning.isChannelPinned = function (Env, channel, cb) { + return void cb(void 0, true); // XXX +/* // if the pins are fully loaded then you can answer yes/no definitively if (Env.pinsLoaded) { return void cb(void 0, !isEmpty(Env.pinnedPads[channel])); @@ -559,5 +561,6 @@ Pinning.isChannelPinned = function (Env, channel, cb) { // as you learn that one account has pinned a file. // negative responses have to wait until the end deferResponse(Env, channel, cb); +*/ }; diff --git a/lib/hk-util.js b/lib/hk-util.js index 3f0aed360..cb9e9b8ef 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -436,7 +436,8 @@ const storeMessage = function (Env, channel, msg, isCp, optionalMessageHash) { * -1 if you didn't find it */ -const getHistoryOffset = (Env, channelName, lastKnownHash, cb) => { +const getHistoryOffset = (Env, channelName, lastKnownHash, _cb) => { + const cb = Util.once(Util.mkAsync(_cb)); const store = Env.store; const Log = Env.Log; diff --git a/lib/rpc.js b/lib/rpc.js index c54edf31d..241f77d41 100644 --- a/lib/rpc.js +++ b/lib/rpc.js @@ -198,7 +198,7 @@ RPC.create = function (Env, cb) { updateLimitDaily(); Env.intervals.dailyLimitUpdate = setInterval(updateLimitDaily, 24*3600*1000); - Pinning.loadChannelPins(Env); + //Pinning.loadChannelPins(Env); // XXX // expire old sessions once per minute Env.intervals.sessionExpirationInterval = setInterval(function () { diff --git a/lib/storage/file.js b/lib/storage/file.js index 6d2c672a5..053ecc9c7 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -101,6 +101,9 @@ var getMetadataAtPath = function (Env, path, _cb) { if (i++ > 0) { console.log("aborting"); abort(); + try { stream.close(); } catch (err) { + console.log("could not close stream"); + } return void cb(); } var metadata; @@ -890,7 +893,7 @@ var trimChannel = function (env, channelName, hash, _cb) { var retain = false; var handler = function (msgObj, readMore, abort) { - if (ABORT) { return void abort(); } + if (ABORT) { return void abort(); } // XXX // the first message might be metadata... ignore it if so if (i++ === 0 && msgObj.buff.indexOf('{') === 0) { return readMore(); diff --git a/lib/stream-file.js b/lib/stream-file.js index dc44aaf50..c3130365b 100644 --- a/lib/stream-file.js +++ b/lib/stream-file.js @@ -67,7 +67,15 @@ Stream.readFileBin = (stream, msgHandler, cb) => { mkBufferSplit(), mkOffsetCounter(), Pull.asyncMap((data, moreCb) => { - msgHandler(data, moreCb, () => { keepReading = false; moreCb(); }); + msgHandler(data, moreCb, () => { + try { + stream.close(); + } catch (err) { + console.error("READ_FILE_BIN_ERR", err); + } + keepReading = false; + moreCb(); + }); }), Pull.drain(() => (keepReading), (err) => { cb((keepReading) ? err : undefined); diff --git a/www/kanban/inner.js b/www/kanban/inner.js index ade42f271..ab7b98066 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -102,6 +102,8 @@ define([ } html += cursor.name + ''; + // XXX breaks on "😶" + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt#Getting_whole_characters var l = (cursor.name || Messages.anonymous).slice(0,1).toUpperCase(); var text = ''; @@ -786,6 +788,7 @@ define([ var boardExists = function (b) { return b.id === "board" + counter; }; while (kanban.options.boards.some(boardExists)) { counter++; } */ + // XXX confirm that it doesn't collide with an existing id? unlikely but possible var id = Util.createRandomInteger(); kanban.addBoard({