diff --git a/.gitignore b/.gitignore index 0f6dc1d9d..91311b687 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ dependency/ \.nyc_output/ coverage/* + +\.vscode/ diff --git a/AABrowserAPI/CopySimulator.js b/AABrowserAPI/CopySimulator.js index 4e8e19046..b6caf92b8 100644 --- a/AABrowserAPI/CopySimulator.js +++ b/AABrowserAPI/CopySimulator.js @@ -1,5 +1,6 @@ -const beautify = require("json-beautify"); +const beautify = require("json-beautify") const { logger } = require('../logs/logger') +const util = require('util') exports.newCopySimulator = function newCopySimulator(pStorage) { @@ -89,7 +90,7 @@ exports.newCopySimulator = function newCopySimulator(pStorage) { // Delete simulator code let newSimulatorName = "simulator-" + pBotCodeName + "-Indicator-Bot" - let newSimulatorPath = pTeamCodeName + "/bots/" + newSimulatorName + let newSimulatorPath = "bots/" + newSimulatorName await deleteBlob(pTeamCodeName, newSimulatorPath, "Commons.js") await deleteBlob(pTeamCodeName, newSimulatorPath, "this.bot.config.json") await deleteBlob(pTeamCodeName, newSimulatorPath + "/Multi-Period-Daily", "User.Bot.js") @@ -131,13 +132,14 @@ exports.newCopySimulator = function newCopySimulator(pStorage) { }) let writeData = util.promisify(storage.writeData) - await writeData(teamName, containerName, blobName, content) + let response = await writeData(teamName, containerName, blobName, content) + return response } async function deleteBlob(teamName, containerName, blobName) { try { storage.deleteBlob[util.promisify.custom] = n => new Promise((resolve, reject) => { - storage.deleteBlob(pOrg, pPath, pFile, (err, value) => { + storage.deleteBlob(teamName, containerName, blobName, (err, value) => { if (err.result !== global.DEFAULT_OK_RESPONSE.result) { reject(err) } else { @@ -147,7 +149,8 @@ exports.newCopySimulator = function newCopySimulator(pStorage) { }) let deleteBlob = util.promisify(storage.deleteBlob) - await deleteBlob(teamName, containerName, blobName) + let response = await deleteBlob() + return response } catch (err) { logger.warn('Error deleting the file: %s%s', containerName, blobName) } diff --git a/AABrowserAPI/TeamSetup.js b/AABrowserAPI/TeamSetup.js index c7d5bef28..68c9a767b 100644 --- a/AABrowserAPI/TeamSetup.js +++ b/AABrowserAPI/TeamSetup.js @@ -308,7 +308,7 @@ } const newCopySimulator = require("./CopySimulator") - let copySimulator = newCopySimulator.newCopySimulator() + let copySimulator = newCopySimulator.newCopySimulator(storage) await copySimulator.copySimulator(pTeamCodeName, pBotCodeName, pBotDisplayName) forkAACloud(); @@ -885,7 +885,7 @@ } const newCopySimulator = require("./CopySimulator") - let copySimulator = newCopySimulator.newCopySimulator() + let copySimulator = newCopySimulator.newCopySimulator(storage) await copySimulator.removeSimulator(pTeamCodeName, pBotCodeName) deleteAACloud(); diff --git a/Server/MinioStorage.js b/Server/MinioStorage.js index 180bc03cc..0a282549a 100644 --- a/Server/MinioStorage.js +++ b/Server/MinioStorage.js @@ -80,7 +80,7 @@ if (err) { onFileReceived(err, null, "Error retrieving file " + textFilename + " from bucket " + bucketName); - return + return } dataStream.on('data', function (chunk) { data += chunk @@ -319,7 +319,7 @@ /* ContainerAlreadyExists check */ - if (JSON.stringify(err).indexOf("ContainerNotFound") > 0) { + if (err.code === "NoSuchBucket") { let err = { resutl: global.CUSTOM_FAIL_RESPONSE.result, @@ -348,4 +348,4 @@ callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } -} \ No newline at end of file +}