From fd96e016872f4a3d1633edc7d965571c48629b47 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Thu, 3 Jun 2021 13:27:05 +0300 Subject: [PATCH] [license] Return original license on 'license' command --- Common/sources/license.js | 4 ++-- DocService/sources/DocsCoServer.js | 6 ++++-- DocService/sources/server.js | 6 +++--- FileConverter/sources/convertermaster.js | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Common/sources/license.js b/Common/sources/license.js index ea257bdc..c651c605 100644 --- a/Common/sources/license.js +++ b/Common/sources/license.js @@ -39,7 +39,7 @@ const oBuildDate = new Date(buildDate); exports.readLicense = function*() { const c_LR = constants.LICENSE_RESULT; - return { + return [{ count: 1, type: c_LR.Success, light: false, @@ -54,7 +54,7 @@ exports.readLicense = function*() { plugins: false, buildDate: oBuildDate, endDate: null - }; + }, null]; }; exports.packageType = constants.PACKAGE_TYPE_OS; diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index f48ce1ef..ea099a90 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -165,6 +165,7 @@ let lockDocumentsTimerId = {};//to drop connection that can't unlockDocument let pubsub; let queue; let licenseInfo = {type: constants.LICENSE_RESULT.Error, light: false, branding: false, customization: false, plugins: false}; +let licenseOriginal = null; let shutdownFlag = false; let expDocumentsStep = gc.getCronStep(cfgExpDocumentsCron); @@ -3132,8 +3133,9 @@ exports.install = function(server, callbackFunction) { }); }); }; -exports.setLicenseInfo = function(data) { +exports.setLicenseInfo = function(data, original ) { licenseInfo = data; + licenseOriginal = original; }; exports.getLicenseInfo = function() { return licenseInfo; @@ -3273,7 +3275,7 @@ let commandLicense = co.wrap(function*() { const nowUTC = getLicenseNowUtc(); let users = yield editorData.getPresenceUniqueUser(nowUTC); return { - license: utils.convertLicenseInfoToFileParams(licenseInfo), + license: licenseOriginal || utils.convertLicenseInfoToFileParams(licenseInfo), server: utils.convertLicenseInfoToServerParams(licenseInfo), quota: {users: users} }; diff --git a/DocService/sources/server.js b/DocService/sources/server.js index 2ea7149c..8df00427 100644 --- a/DocService/sources/server.js +++ b/DocService/sources/server.js @@ -63,7 +63,7 @@ app.set("views", cfgHtmlTemplate); app.set("view engine", "ejs"); const server = http.createServer(app); -let licenseInfo, updatePluginsTime, userPlugins, pluginsLoaded; +let licenseInfo, licenseOriginal, updatePluginsTime, userPlugins, pluginsLoaded; const updatePlugins = (eventType, filename) => { console.log('update Folder: %s ; %s', eventType, filename); @@ -75,13 +75,13 @@ const updatePlugins = (eventType, filename) => { pluginsLoaded = false; }; const readLicense = function*() { - licenseInfo = yield* license.readLicense(); + [licenseInfo, licenseOriginal] = yield* license.readLicense(); }; const updateLicense = () => { return co(function*() { try { yield* readLicense(); - docsCoServer.setLicenseInfo(licenseInfo); + docsCoServer.setLicenseInfo(licenseInfo, licenseOriginal); console.log('End updateLicense'); } catch (err) { logger.error('updateLicense error:\r\n%s', err.stack); diff --git a/FileConverter/sources/convertermaster.js b/FileConverter/sources/convertermaster.js index c246bb84..2c4526f8 100644 --- a/FileConverter/sources/convertermaster.js +++ b/FileConverter/sources/convertermaster.js @@ -46,7 +46,7 @@ if (cluster.isMaster) { const cfgMaxProcessCount = config.get('maxprocesscount'); var licenseInfo, workersCount = 0; const readLicense = function* () { - licenseInfo = yield* license.readLicense(); + [licenseInfo] = yield* license.readLicense(); workersCount = Math.min(licenseInfo.count, Math.ceil(numCPUs * cfgMaxProcessCount)); }; const updateWorkers = () => {