From d0466a205231320e2a964fea06e7f798e07ed8b0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 15 Mar 2017 15:46:23 +0100 Subject: [PATCH] implement 'getChannelSize' api in storage --- storage/file.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/storage/file.js b/storage/file.js index 1584f4a59..ab2bce617 100644 --- a/storage/file.js +++ b/storage/file.js @@ -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) { var env = { root: conf.filePath || './datastore', @@ -248,6 +256,9 @@ module.exports.create = function (conf, cb) { flushUnusedChannels: function (cb) { flushUnusedChannels(env, cb); }, + getChannelSize: function (chanName, cb) { + channelBytes(env, chanName, cb); + }, }); }); setInterval(function () {