diff --git a/rpc.js b/rpc.js index c7312ec0c..e54362e98 100644 --- a/rpc.js +++ b/rpc.js @@ -686,7 +686,7 @@ var clearOwnedChannel = function (Env, channelId, unsafeKey, cb) { } Env.msgStore.getChannelMetadata(channelId, function (e, metadata) { - if (e) { return Respond(e); } + if (e) { return cb(e); } if (!(metadata && Array.isArray(metadata.owners))) { return void cb('E_NO_OWNERS'); } // Confirm that the channel is owned by the user is question if (metadata.owners.indexOf(unsafeKey) === -1) { diff --git a/storage/file.js b/storage/file.js index ca293c777..4daf24cde 100644 --- a/storage/file.js +++ b/storage/file.js @@ -44,6 +44,18 @@ var getChannelMetadata = function (Env, channelId, cb) { getMetadataAtPath(Env, path, cb); }; +var closeChannel = function (env, channelName, cb) { + if (!env.channels[channelName]) { return; } + try { + env.channels[channelName].writeStream.close(); + delete env.channels[channelName]; + env.openFiles--; + cb(); + } catch (err) { + cb(err); + } +}; + var clearChannel = function (Env, channelId, cb) { var path = mkPath(Env, channelId); getMetadataAtPath(Env, path, function (e, metadata) { @@ -112,18 +124,6 @@ var removeChannel = function (env, channelName, cb) { Fs.unlink(filename, cb); }; -var closeChannel = function (env, channelName, cb) { - if (!env.channels[channelName]) { return; } - try { - env.channels[channelName].writeStream.close(); - delete env.channels[channelName]; - env.openFiles--; - cb(); - } catch (err) { - cb(err); - } -}; - var flushUnusedChannels = function (env, cb, frame) { var currentTime = +new Date();