label code that will need to change for editable metadata

pull/1/head
ansuz 5 years ago
parent 60673103ad
commit 46cd796db5

@ -61,13 +61,13 @@ module.exports.create = function (cfg) {
const cpIndex = [];
let messageBuf = [];
let validateKey;
let metadata;
let metadata; // FIXME METADATA
let i = 0;
store.readMessagesBin(channelName, 0, (msgObj, rmcb) => {
let msg;
i++;
if (!validateKey && msgObj.buff.indexOf('validateKey') > -1) {
metadata = msg = tryParse(msgObj.buff.toString('utf8'));
metadata = msg = tryParse(msgObj.buff.toString('utf8')); // FIXME METADATA
if (typeof msg === "undefined") { return rmcb(); }
if (msg.validateKey) {
validateKey = historyKeeperKeys[channelName] = msg;
@ -105,7 +105,7 @@ module.exports.create = function (cfg) {
cpIndex: sliceCpIndex(cpIndex, i),
offsetByHash: offsetByHash,
size: size,
metadata: metadata,
metadata: metadata, // FIXME METADATA
line: i
});
});
@ -438,16 +438,16 @@ module.exports.create = function (cfg) {
so, let's just fall through...
*/
if (err) { return w(); }
if (!index || !index.metadata) { return void w(); }
if (!index || !index.metadata) { return void w(); } // FIXME METADATA
// Store the metadata if we don't have it in memory
if (!historyKeeperKeys[channelName]) {
historyKeeperKeys[channelName] = index.metadata;
historyKeeperKeys[channelName] = index.metadata; // FIXME METADATA
}
// And then check if the channel is expired. If it is, send the error and abort
if (checkExpired(ctx, channelName)) { return void waitFor.abort(); }
// Send the metadata to the user
if (!lastKnownHash && index.cpIndex.length > 1) {
sendMsg(ctx, user, [0, HISTORY_KEEPER_ID, 'MSG', user.id, JSON.stringify(index.metadata)], w);
sendMsg(ctx, user, [0, HISTORY_KEEPER_ID, 'MSG', user.id, JSON.stringify(index.metadata)], w); // FIXME METADATA
return;
}
w();
@ -494,8 +494,8 @@ module.exports.create = function (cfg) {
key.expire = expire;
}
historyKeeperKeys[channelName] = key;
storeMessage(ctx, chan, JSON.stringify(key), false, undefined);
sendMsg(ctx, user, [0, HISTORY_KEEPER_ID, 'MSG', user.id, JSON.stringify(key)]);
storeMessage(ctx, chan, JSON.stringify(key), false, undefined); // FIXME METADATA
sendMsg(ctx, user, [0, HISTORY_KEEPER_ID, 'MSG', user.id, JSON.stringify(key)]); // FIXME METADATA
}
// End of history message:

@ -1722,7 +1722,7 @@ RPC.create = function (
respond(e, [null, size, null]);
});
case 'GET_METADATA':
return void getMetadata(Env, msg[1], function (e, data) {
return void getMetadata(Env, msg[1], function (e, data) { // FIXME METADATA
WARN(e, msg[1]);
respond(e, [null, data, null]);
});

@ -60,6 +60,7 @@ var getMetadataAtPath = function (Env, path, cb) {
stream.on('error', function (e) { complete(e); });
};
// FIXME METADATA
var getChannelMetadata = function (Env, channelId, cb) {
var path = mkPath(Env, channelId);
getMetadataAtPath(Env, path, cb);
@ -255,6 +256,9 @@ var listChannels = function (root, handler, cb) {
var wait = w();
dirList.forEach(function (dir) {
sema.take(function (give) {
// TODO modify the asynchronous bits here to keep less in memory at any given time
// list a directory -> process its contents with semaphores until less than N jobs are running
// then list the next directory...
var nestedDirPath = Path.join(root, dir);
Fs.readdir(nestedDirPath, w(give(function (err, list) {
if (err) { return void handler(err); } // Is this correct?
@ -600,7 +604,7 @@ module.exports.create = function (
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
channelBytes(env, channelName, cb);
},
getChannelMetadata: function (channelName, cb) {
getChannelMetadata: function (channelName, cb) { // FIXME METADATA
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
getChannelMetadata(env, channelName, cb);
},

Loading…
Cancel
Save