From c0d908af4df09c05ac8432ab421fdb0470a2c41e Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 13 Jun 2019 11:20:53 +0200 Subject: [PATCH] implement 'unarchiveChannel' --- storage/file.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/storage/file.js b/storage/file.js index 86aea935c..1f8c00a0c 100644 --- a/storage/file.js +++ b/storage/file.js @@ -301,6 +301,19 @@ var archiveChannel = function (env, channelName, cb) { Fse.move(currentPath, archivePath, { overwrite: true }, cb); }; +var unarchiveChannel = function (env, channelName, cb) { + // very much like 'archiveChannel' but in the opposite direction + + // the file is currently archived + var currentPath = mkArchivePath(env, channelName); + var unarchivedPath = mkPath(env, channelName); + + // if a file exists in the unarchived path, you probably don't want to clobber its data + // so unlike 'archiveChannel' we won't overwrite. + // Fse.move will call back with EEXIST in such a situation + Fse.move(currentPath, unarchivedPath, cb); +}; + var flushUnusedChannels = function (env, cb, frame) { var currentTime = +new Date(); @@ -589,6 +602,10 @@ module.exports.create = function ( if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } archiveChannel(env, channelName, cb); }, + unarchiveChannel: function (channelName, cb) { + if (!isValidChannelId(channelName)) { return void cb(new Error('EINVAL')); } + unarchiveChannel(env, channelName, cb); + }, log: function (channelName, content, cb) { message(env, channelName, content, cb); },