Merge branch 'soon' of github.com:xwiki-labs/cryptpad into soon
This commit is contained in:
commit
a6f8160ab4
@ -547,8 +547,9 @@ const deferResponse = function (Env, channel, cb) {
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME this will be removed from the client
|
||||||
Pinning.isChannelPinned = function (Env, channel, cb) {
|
Pinning.isChannelPinned = function (Env, channel, cb) {
|
||||||
return void cb(void 0, true); // XXX
|
return void cb(void 0, true);
|
||||||
/*
|
/*
|
||||||
// if the pins are fully loaded then you can answer yes/no definitively
|
// if the pins are fully loaded then you can answer yes/no definitively
|
||||||
if (Env.pinsLoaded) {
|
if (Env.pinsLoaded) {
|
||||||
|
|||||||
@ -15,18 +15,15 @@ const init = function (config, cb) {
|
|||||||
return void cb('E_INVALID_CONFIG');
|
return void cb('E_INVALID_CONFIG');
|
||||||
}
|
}
|
||||||
|
|
||||||
Store.create(config, function (_store) {
|
Store.create(config, function (err, _store) {
|
||||||
|
if (err) { return void cb(err); }
|
||||||
store = _store;
|
store = _store;
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const tryParse = function (Env, str) {
|
const tryParse = function (Env, str) {
|
||||||
try {
|
try { return JSON.parse(str); } catch (err) { }
|
||||||
return JSON.parse(str);
|
|
||||||
} catch (err) {
|
|
||||||
// XXX
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* computeIndex
|
/* computeIndex
|
||||||
|
|||||||
@ -215,12 +215,14 @@ module.exports.create = function (config, cb) {
|
|||||||
// create a pin store
|
// create a pin store
|
||||||
Store.create({
|
Store.create({
|
||||||
filePath: pinPath,
|
filePath: pinPath,
|
||||||
}, w(function (s) {
|
}, w(function (err, s) {
|
||||||
|
if (err) { throw err; }
|
||||||
Env.pinStore = s;
|
Env.pinStore = s;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// create a channel store
|
// create a channel store
|
||||||
Store.create(config, w(function (_store) {
|
Store.create(config, w(function (err, _store) {
|
||||||
|
if (err) { throw err; }
|
||||||
config.store = _store;
|
config.store = _store;
|
||||||
Env.msgStore = _store; // API used by rpc
|
Env.msgStore = _store; // API used by rpc
|
||||||
Env.store = _store; // API used by historyKeeper
|
Env.store = _store; // API used by historyKeeper
|
||||||
|
|||||||
@ -835,7 +835,14 @@ HK.initializeIndexWorkers = function (Env, config, _cb) {
|
|||||||
worker.on('message', function (res) {
|
worker.on('message', function (res) {
|
||||||
if (!res || !res.txid) { return; }
|
if (!res || !res.txid) { return; }
|
||||||
//console.log(res);
|
//console.log(res);
|
||||||
|
try {
|
||||||
response.handle(res.txid, [res.error, res.value]);
|
response.handle(res.txid, [res.error, res.value]);
|
||||||
|
} catch (err) {
|
||||||
|
Env.Log.error("INDEX_WORKER", {
|
||||||
|
error: err,
|
||||||
|
response: res,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
worker.on('exit', function () {
|
worker.on('exit', function () {
|
||||||
var idx = workers.indexOf(worker);
|
var idx = workers.indexOf(worker);
|
||||||
|
|||||||
@ -96,12 +96,17 @@ Logger.create = function (config, cb) {
|
|||||||
|
|
||||||
if (!config.logPath) {
|
if (!config.logPath) {
|
||||||
console.log("No logPath configured. Logging to file disabled");
|
console.log("No logPath configured. Logging to file disabled");
|
||||||
return void cb(Object.freeze(createMethods(ctx)));
|
var logger = createMethods(ctx);
|
||||||
|
logger.shutdown = noop;
|
||||||
|
return void cb(Object.freeze(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
Store.create({
|
Store.create({
|
||||||
filePath: config.logPath,
|
filePath: config.logPath,
|
||||||
}, function (store) {
|
}, function (err, store) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
ctx.store = store;
|
ctx.store = store;
|
||||||
var logger = createMethods(ctx);
|
var logger = createMethods(ctx);
|
||||||
logger.shutdown = function () {
|
logger.shutdown = function () {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const UNAUTHENTICATED_CALLS = {
|
|||||||
GET_FILE_SIZE: Pinning.getFileSize,
|
GET_FILE_SIZE: Pinning.getFileSize,
|
||||||
GET_MULTIPLE_FILE_SIZE: Pinning.getMultipleFileSize,
|
GET_MULTIPLE_FILE_SIZE: Pinning.getMultipleFileSize,
|
||||||
GET_DELETED_PADS: Pinning.getDeletedPads,
|
GET_DELETED_PADS: Pinning.getDeletedPads,
|
||||||
IS_CHANNEL_PINNED: Pinning.isChannelPinned,
|
IS_CHANNEL_PINNED: Pinning.isChannelPinned, // FIXME drop this RPC
|
||||||
IS_NEW_CHANNEL: Channel.isNewChannel,
|
IS_NEW_CHANNEL: Channel.isNewChannel,
|
||||||
WRITE_PRIVATE_MESSAGE: Channel.writePrivateMessage,
|
WRITE_PRIVATE_MESSAGE: Channel.writePrivateMessage,
|
||||||
GET_METADATA: Metadata.getMetadata,
|
GET_METADATA: Metadata.getMetadata,
|
||||||
@ -198,8 +198,6 @@ RPC.create = function (Env, cb) {
|
|||||||
updateLimitDaily();
|
updateLimitDaily();
|
||||||
Env.intervals.dailyLimitUpdate = setInterval(updateLimitDaily, 24*3600*1000);
|
Env.intervals.dailyLimitUpdate = setInterval(updateLimitDaily, 24*3600*1000);
|
||||||
|
|
||||||
//Pinning.loadChannelPins(Env); // XXX
|
|
||||||
|
|
||||||
// expire old sessions once per minute
|
// expire old sessions once per minute
|
||||||
Env.intervals.sessionExpirationInterval = setInterval(function () {
|
Env.intervals.sessionExpirationInterval = setInterval(function () {
|
||||||
Core.expireSessions(Sessions);
|
Core.expireSessions(Sessions);
|
||||||
|
|||||||
@ -951,7 +951,9 @@ var trimChannel = function (env, channelName, hash, _cb) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.create = function (conf, cb) {
|
module.exports.create = function (conf, _cb) {
|
||||||
|
var cb = Util.once(Util.mkAsync(_cb));
|
||||||
|
|
||||||
var env = {
|
var env = {
|
||||||
root: conf.filePath || './datastore',
|
root: conf.filePath || './datastore',
|
||||||
archiveRoot: conf.archivePath || './data/archive',
|
archiveRoot: conf.archivePath || './data/archive',
|
||||||
@ -984,18 +986,19 @@ module.exports.create = function (conf, cb) {
|
|||||||
// make sure the store's directory exists
|
// make sure the store's directory exists
|
||||||
Fse.mkdirp(env.root, PERMISSIVE, w(function (err) {
|
Fse.mkdirp(env.root, PERMISSIVE, w(function (err) {
|
||||||
if (err && err.code !== 'EEXIST') {
|
if (err && err.code !== 'EEXIST') {
|
||||||
throw err; // XXX
|
w.abort();
|
||||||
|
return void cb(err);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
// make sure the cold storage directory exists
|
// make sure the cold storage directory exists
|
||||||
Fse.mkdirp(env.archiveRoot, PERMISSIVE, w(function (err) {
|
Fse.mkdirp(env.archiveRoot, PERMISSIVE, w(function (err) {
|
||||||
if (err && err.code !== 'EEXIST') {
|
if (err && err.code !== 'EEXIST') {
|
||||||
throw err; // XXX
|
w.abort();
|
||||||
|
return void cb(err);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}).nThen(function () {
|
}).nThen(function () {
|
||||||
// XXX leave a place for an error
|
cb(void 0, {
|
||||||
cb({
|
|
||||||
// OLDER METHODS
|
// OLDER METHODS
|
||||||
// write a new message to a log
|
// write a new message to a log
|
||||||
message: function (channelName, content, cb) {
|
message: function (channelName, content, cb) {
|
||||||
|
|||||||
@ -8,7 +8,11 @@ var Log;
|
|||||||
nThen(function (w) {
|
nThen(function (w) {
|
||||||
// load the store which will be used for iterating over channels
|
// load the store which will be used for iterating over channels
|
||||||
// and performing operations like archival and deletion
|
// and performing operations like archival and deletion
|
||||||
Store.create(config, w(function (_) {
|
Store.create(config, w(function (err, _) {
|
||||||
|
if (err) {
|
||||||
|
w.abort();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
store = _;
|
store = _;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,11 @@ var msSinceStart = function () {
|
|||||||
nThen(function (w) {
|
nThen(function (w) {
|
||||||
// load the store which will be used for iterating over channels
|
// load the store which will be used for iterating over channels
|
||||||
// and performing operations like archival and deletion
|
// and performing operations like archival and deletion
|
||||||
Store.create(config, w(function (_) {
|
Store.create(config, w(function (err, _) {
|
||||||
|
if (err) {
|
||||||
|
w.abort();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
store = _;
|
store = _;
|
||||||
})); // load the list of pinned files so you know which files
|
})); // load the list of pinned files so you know which files
|
||||||
// should not be archived or deleted
|
// should not be archived or deleted
|
||||||
|
|||||||
@ -8,7 +8,8 @@ var Log;
|
|||||||
nThen(function (w) {
|
nThen(function (w) {
|
||||||
// load the store which will be used for iterating over channels
|
// load the store which will be used for iterating over channels
|
||||||
// and performing operations like archival and deletion
|
// and performing operations like archival and deletion
|
||||||
Store.create(config, w(function (_) {
|
Store.create(config, w(function (err, _) {
|
||||||
|
if (err) { throw err; }
|
||||||
store = _;
|
store = _;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user