From fe537dff3b219c7d3246f04b6357001aea855802 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Apr 2020 13:27:20 +0200 Subject: [PATCH] bugs fixed --- DataDependencies.js | 5 +++-- FileStorage.js | 14 ++++++++++++-- StatusDependencies.js | 3 ++- StatusReport.js | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/DataDependencies.js b/DataDependencies.js index 4f646a80c..3ea9ea759 100644 --- a/DataDependencies.js +++ b/DataDependencies.js @@ -105,10 +105,11 @@ } function finalize() { - for (let i = 0; i < dataSetsModulesArray.length; i++) { - dataSetsModule = dataSetsModulesArray[i] + for (let i = 0; i < thisObject.dataSetsModulesArray.length; i++) { + let dataSetModule = thisObject.dataSetsModulesArray[i] dataSetModule.finalize() } + thisObject.dataSetsModulesArray = undefined filter = undefined bot = undefined thisObject = undefined diff --git a/FileStorage.js b/FileStorage.js index 7dff0ea37..199183aa3 100644 --- a/FileStorage.js +++ b/FileStorage.js @@ -149,6 +149,7 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { } else { logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> Could read the file, but could not parse it as it is not a valid JSON.') logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> err = ' + err.stack) + logger.write(MODULE_NAME, '[WARN] FileStorage -> getTextFile -> onFileRead -> text.toString() = ' + text.toString()) setTimeout(retry, retryTimeToUse) return } @@ -437,6 +438,9 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { function getFileViaHTTP(filePath, callback) { try { + /* The filePath received is the one that is needed to fetch data from with fs. To do it via http we need to remove the prefix that includes this: ./Data-Storage/ */ + filePath = filePath.substring(15, filePath.length) + let http = require('http'); let url = 'http://' + host + ':' + port + @@ -458,8 +462,14 @@ exports.newFileStorage = function newFileStorage(logger, host, port) { function onEnd() { let fileContent = Buffer.concat(chunks).toString('utf8') - - callback(null, fileContent) + let err = null + if (fileContent === 'The specified key does not exist.') { + err = { + code: "ENOENT" // This is how fs would have returned upon this situation. + } + fileContent = undefined + } + callback(err, fileContent) } } diff --git a/StatusDependencies.js b/StatusDependencies.js index 8dcc1bd67..48b5659a9 100644 --- a/StatusDependencies.js +++ b/StatusDependencies.js @@ -167,10 +167,11 @@ } function finalize() { - statusReports.forEach(forEachStatusDependency) + thisObject.statusReports.forEach(forEachStatusDependency) function forEachStatusDependency(statusDependency) { statusDependency.finalize() } + thisObject.statusReports = undefined bot = undefined thisObject = undefined } diff --git a/StatusReport.js b/StatusReport.js index 99fb2fc28..4648c1a94 100644 --- a/StatusReport.js +++ b/StatusReport.js @@ -258,6 +258,7 @@ */ logger.write(MODULE_NAME, "[ERROR] load -> onFileReceived -> Error Parsing the Status report. -> Err = " + err.message); + logger.write(MODULE_NAME, "[WARN] load -> onFileReceived -> Error Parsing the Status report. -> text = " + text); let customFail = { result: global.CUSTOM_FAIL_RESPONSE.result,