From a2c8ec963ce3715c9215bbbb1f0fa382ecfc9a6c Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 13 Jun 2019 16:44:27 +0200 Subject: [PATCH] archive files deleted by 'removeOwnedChannel' if the admin has configured that behaviour --- rpc.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rpc.js b/rpc.js index 19d482368..a69033cc1 100644 --- a/rpc.js +++ b/rpc.js @@ -902,9 +902,19 @@ var removeOwnedChannel = function (Env, channelId, unsafeKey, cb) { return void cb('INSUFFICIENT_PERMISSIONS'); } - // FIXME COLDSTORAGE - // XXX check if 'config.retainData' is set to true - // if so, use msgStore.archiveChannel instead + // if the admin has configured data retention... + // temporarily archive the file instead of removing it + if (Env.retainData) { + return void Env.msgStore.archiveChannel(channelId, function (e) { + Log.info('ARCHIVAL_CHANNEL_BY_OWNER_RPC', { + unsafeKey: unsafeKey, + channelId: channelId, + status: e? String(e): 'SUCCESS', + }); + cb(e); + }); + } + return void Env.msgStore.removeChannel(channelId, function (e) { Log.info('DELETION_CHANNEL_BY_OWNER_RPC', { unsafeKey: unsafeKey, @@ -1651,6 +1661,7 @@ RPC.create = function ( }; var Env = { + retainData: config.retainData || false, defaultStorageLimit: config.defaultStorageLimit, maxUploadSize: config.maxUploadSize || (20 * 1024 * 1024), Sessions: {},