label code that will need to change for editable metadata
This commit is contained in:
parent
60673103ad
commit
46cd796db5
@ -61,13 +61,13 @@ module.exports.create = function (cfg) {
|
|||||||
const cpIndex = [];
|
const cpIndex = [];
|
||||||
let messageBuf = [];
|
let messageBuf = [];
|
||||||
let validateKey;
|
let validateKey;
|
||||||
let metadata;
|
let metadata; // FIXME METADATA
|
||||||
let i = 0;
|
let i = 0;
|
||||||
store.readMessagesBin(channelName, 0, (msgObj, rmcb) => {
|
store.readMessagesBin(channelName, 0, (msgObj, rmcb) => {
|
||||||
let msg;
|
let msg;
|
||||||
i++;
|
i++;
|
||||||
if (!validateKey && msgObj.buff.indexOf('validateKey') > -1) {
|
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 (typeof msg === "undefined") { return rmcb(); }
|
||||||
if (msg.validateKey) {
|
if (msg.validateKey) {
|
||||||
validateKey = historyKeeperKeys[channelName] = msg;
|
validateKey = historyKeeperKeys[channelName] = msg;
|
||||||
@ -105,7 +105,7 @@ module.exports.create = function (cfg) {
|
|||||||
cpIndex: sliceCpIndex(cpIndex, i),
|
cpIndex: sliceCpIndex(cpIndex, i),
|
||||||
offsetByHash: offsetByHash,
|
offsetByHash: offsetByHash,
|
||||||
size: size,
|
size: size,
|
||||||
metadata: metadata,
|
metadata: metadata, // FIXME METADATA
|
||||||
line: i
|
line: i
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -438,16 +438,16 @@ module.exports.create = function (cfg) {
|
|||||||
so, let's just fall through...
|
so, let's just fall through...
|
||||||
*/
|
*/
|
||||||
if (err) { return w(); }
|
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
|
// Store the metadata if we don't have it in memory
|
||||||
if (!historyKeeperKeys[channelName]) {
|
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
|
// And then check if the channel is expired. If it is, send the error and abort
|
||||||
if (checkExpired(ctx, channelName)) { return void waitFor.abort(); }
|
if (checkExpired(ctx, channelName)) { return void waitFor.abort(); }
|
||||||
// Send the metadata to the user
|
// Send the metadata to the user
|
||||||
if (!lastKnownHash && index.cpIndex.length > 1) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
w();
|
w();
|
||||||
@ -494,8 +494,8 @@ module.exports.create = function (cfg) {
|
|||||||
key.expire = expire;
|
key.expire = expire;
|
||||||
}
|
}
|
||||||
historyKeeperKeys[channelName] = key;
|
historyKeeperKeys[channelName] = key;
|
||||||
storeMessage(ctx, chan, JSON.stringify(key), false, undefined);
|
storeMessage(ctx, chan, JSON.stringify(key), false, undefined); // FIXME METADATA
|
||||||
sendMsg(ctx, user, [0, HISTORY_KEEPER_ID, 'MSG', user.id, JSON.stringify(key)]);
|
sendMsg(ctx, user, [0, HISTORY_KEEPER_ID, 'MSG', user.id, JSON.stringify(key)]); // FIXME METADATA
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of history message:
|
// End of history message:
|
||||||
|
|||||||
2
rpc.js
2
rpc.js
@ -1722,7 +1722,7 @@ RPC.create = function (
|
|||||||
respond(e, [null, size, null]);
|
respond(e, [null, size, null]);
|
||||||
});
|
});
|
||||||
case 'GET_METADATA':
|
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]);
|
WARN(e, msg[1]);
|
||||||
respond(e, [null, data, null]);
|
respond(e, [null, data, null]);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -60,6 +60,7 @@ var getMetadataAtPath = function (Env, path, cb) {
|
|||||||
stream.on('error', function (e) { complete(e); });
|
stream.on('error', function (e) { complete(e); });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME METADATA
|
||||||
var getChannelMetadata = function (Env, channelId, cb) {
|
var getChannelMetadata = function (Env, channelId, cb) {
|
||||||
var path = mkPath(Env, channelId);
|
var path = mkPath(Env, channelId);
|
||||||
getMetadataAtPath(Env, path, cb);
|
getMetadataAtPath(Env, path, cb);
|
||||||
@ -255,6 +256,9 @@ var listChannels = function (root, handler, cb) {
|
|||||||
var wait = w();
|
var wait = w();
|
||||||
dirList.forEach(function (dir) {
|
dirList.forEach(function (dir) {
|
||||||
sema.take(function (give) {
|
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);
|
var nestedDirPath = Path.join(root, dir);
|
||||||
Fs.readdir(nestedDirPath, w(give(function (err, list) {
|
Fs.readdir(nestedDirPath, w(give(function (err, list) {
|
||||||
if (err) { return void handler(err); } // Is this correct?
|
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')); }
|
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
|
||||||
channelBytes(env, channelName, cb);
|
channelBytes(env, channelName, cb);
|
||||||
},
|
},
|
||||||
getChannelMetadata: function (channelName, cb) {
|
getChannelMetadata: function (channelName, cb) { // FIXME METADATA
|
||||||
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
|
if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); }
|
||||||
getChannelMetadata(env, channelName, cb);
|
getChannelMetadata(env, channelName, cb);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user