include the size of the metadata log in the computed size of a channel

This commit is contained in:
ansuz 2019-08-21 12:14:49 +02:00
parent 2aebadcff3
commit d6d7f4f601

View file

@ -569,15 +569,38 @@ var flushUnusedChannels = function (env, cb, frame) {
cb();
};
/* channelBytes
calls back with the size (in bytes) of a channel and its metadata
*/
var channelBytes = function (env, chanName, cb) {
var path = mkPath(env, chanName);
Fs.stat(path, function (err, stats) {
if (err) { return void cb(err); }
cb(undefined, stats.size);
var channelPath = mkPath(env, chanName);
var dataPath = mkMetadataPath(env, chanName);
var CB = Once(cb);
var channelSize = 0;
var dataSize = 0;
nThen(function (w) {
Fs.stat(channelPath, w(function (err, stats) {
if (err) {
if (err.code === 'ENOENT') { return; }
return void CB(err);
}
channelSize = stats.size;
}));
Fs.stat(dataPath, w(function (err, stats) {
if (err) {
if (err.code === 'ENOENT') { return; }
return void CB(err);
}
dataSize = stats.size;
CB(undefined, stats.size);
}));
}).nThen(function () {
CB(void 0, channelSize + dataSize);
});
};
// implement metadata bytes as well?
/*::
export type ChainPadServer_ChannelInternal_t = {
atime: number,