implement 'getChannelSize' api in storage

pull/1/head
ansuz 8 years ago
parent 306f6ce806
commit d0466a2052

@ -216,6 +216,14 @@ var getMessages = function (env, chanName, handler, cb) {
}); });
}; };
var channelBytes = function (env, chanName, cb) {
var path = mkPath(env, chanName);
Fs.stat(path, function (err, stats) {
if (err) { return void cb(err); }
cb(void 0, stats.size);
});
};
module.exports.create = function (conf, cb) { module.exports.create = function (conf, cb) {
var env = { var env = {
root: conf.filePath || './datastore', root: conf.filePath || './datastore',
@ -248,6 +256,9 @@ module.exports.create = function (conf, cb) {
flushUnusedChannels: function (cb) { flushUnusedChannels: function (cb) {
flushUnusedChannels(env, cb); flushUnusedChannels(env, cb);
}, },
getChannelSize: function (chanName, cb) {
channelBytes(env, chanName, cb);
},
}); });
}); });
setInterval(function () { setInterval(function () {

Loading…
Cancel
Save