Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
yflory 5 years ago
commit 747657a559

@ -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) {

@ -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);
*/
};

@ -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;

@ -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 () {

@ -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();

@ -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);

@ -102,6 +102,8 @@ define([
}
html += cursor.name + '</span>';
// 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({

Loading…
Cancel
Save