diff --git a/lib/commands/channel.js b/lib/commands/channel.js index e69f93180..c36c3424d 100644 --- a/lib/commands/channel.js +++ b/lib/commands/channel.js @@ -54,7 +54,8 @@ Channel.clearOwnedChannel = function (Env, safeKey, channelId, cb, Server) { }); }; -var archiveOwnedChannel = function (Env, safeKey, channelId, _cb, Server) { +var archiveOwnedChannel = function (Env, safeKey, channelId, __cb, Server) { + var _cb = Util.once(Util.mkAsync(__cb)); var unsafeKey = Util.unescapeKeyCharacters(safeKey); nThen(function (w) { // confirm that the channel exists before worrying about whether @@ -160,7 +161,10 @@ Channel.trimHistory = function (Env, safeKey, data, cb) { nThen(function (w) { Metadata.getMetadataRaw(Env, channelId, w(function (err, metadata) { - if (err) { return void cb(err); } + if (err) { + w.abort(); + return void cb(err); + } if (!Core.hasOwners(metadata)) { w.abort(); return void cb('E_NO_OWNERS'); @@ -173,6 +177,11 @@ Channel.trimHistory = function (Env, safeKey, data, cb) { })); }).nThen(function () { Env.msgStore.trimChannel(channelId, hash, function (err) { + Env.Log.info('HK_TRIM_HISTORY', { + unsafeKey: unsafeKey, + channelId: channelId, + status: err? String(e): 'SUCCESS', + }); if (err) { return void cb(err); } // clear historyKeeper's cache for this channel Env.historyKeeper.channelClose(channelId);