Saving the bot code and retrieving it without the cache
This commit is contained in:
1 parent
067f4f46f6
commit
cbc9db1f8d
7 files changed
+44
-31
No files matched your search
+14
-14
@@ -65,26 +65,26 @@
|
||||
|
||||
let blobService = storage.createBlobService(connectionString);
|
||||
let blobPath = pOrg + "/" + pRepo + "/" + pPath;
|
||||
let blobText = nodeify(pFileContent.toString());
|
||||
let blobText = nodify(pFileContent.toString());
|
||||
|
||||
blobService.createBlockBlobFromText('aaplatform', blobPath, blobText, onFileReceived);
|
||||
blobService.createBlockBlobFromText('aaplatform', blobPath, blobText, onFileCreated);
|
||||
|
||||
function onFileReceived(err, text, response) {
|
||||
function onFileCreated(err, text, response) {
|
||||
|
||||
try {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileReceived -> Entering function."); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileReceived -> err = " + JSON.stringify(err)); }
|
||||
if (LOG_FILE_CONTENT === true) { console.log("[INFO] API -> writeData -> onFileReceived -> response = " + JSON.stringify(response)); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileReceived -> pOrg = " + pOrg); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileReceived -> pRepo = " + pRepo); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileReceived -> pPath = " + pPath); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileCreated -> Entering function."); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileCreated -> err = " + JSON.stringify(err)); }
|
||||
if (LOG_FILE_CONTENT === true) { console.log("[INFO] API -> writeData -> onFileCreated -> response = " + JSON.stringify(response)); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileCreated -> pOrg = " + pOrg); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileCreated -> pRepo = " + pRepo); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] API -> writeData -> onFileCreated -> pPath = " + pPath); }
|
||||
|
||||
if (err !== null || text === null) {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] API -> writeData -> onFileReceived -> Error Received from API Library. "); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] API -> writeData -> onFileReceived -> err = " + JSON.stringify(err)); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] API -> writeData -> onFileReceived -> Returning an empty JSON object string. "); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] API -> writeData -> onFileCreated -> Error Received from API Library. "); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] API -> writeData -> onFileCreated -> err = " + JSON.stringify(err)); }
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] API -> writeData -> onFileCreated -> Returning an empty JSON object string. "); }
|
||||
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
@@ -94,7 +94,7 @@
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
|
||||
} catch (err) {
|
||||
console.log("[ERROR] API -> writeData -> onFileReceived -> err.message = " + err.message);
|
||||
console.log("[ERROR] API -> writeData -> onFileCreated -> err.message = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function nodeify(pData) {
|
||||
function nodify(pData) {
|
||||
|
||||
|
||||
let start = pData.indexOf('function') + 9;
|
||||
|
||||
+12
-3
@@ -93,7 +93,7 @@ function newCloudVM() {
|
||||
|
||||
if (currentBotCode !== previousBotCode) {
|
||||
|
||||
console.log("Bot code changes detected.");
|
||||
console.log("CloudVM -> Bot code changes detected.");
|
||||
|
||||
let path = "AABrowserAPI" + "/"
|
||||
+ "saveBotCode" + "/"
|
||||
@@ -109,9 +109,18 @@ function newCloudVM() {
|
||||
|
||||
function onServerResponse(err) {
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> onServerResponse -> Entering function."); }
|
||||
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> onServerResponse -> err = " + err); }
|
||||
err = JSON.parse(err);
|
||||
|
||||
if (INFO_LOG === true) { logger.write("[INFO] checkForChangesInBotCode -> onServerResponse -> Entering function."); }
|
||||
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
if (ERROR_LOG === true) { logger.write("[ERROR] checkForChangesInBotCode -> onServerResponse -> err.message = " + err.message); }
|
||||
console.log("CloudVM -> Changes in code NOT saved. Plase check the error log and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("CloudVM -> Changes in code saved.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
function getScript(pDevTeam, pSource, pRepo, pPath, callBackFunction) {
|
||||
|
||||
storage.getStorageData(pDevTeam + "/" + pSource, pRepo, pPath, onDataArrived);
|
||||
storage.getStorageData(pDevTeam + "/" + pSource, pRepo, pPath, false, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
*/
|
||||
|
||||
storage.getStorageData('AdvancedAlgos', 'AACloud', 'web.config.json', onDataArrived);
|
||||
storage.getStorageData('AdvancedAlgos', 'AACloud', 'web.config.json', true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
|
||||
let webModule = pCloudWebConfig.webModules[i].name + '.js';
|
||||
|
||||
storage.getStorageData('AdvancedAlgos', 'AACloud', webModule, onDataArrived);
|
||||
storage.getStorageData('AdvancedAlgos', 'AACloud', webModule, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
|
||||
*/
|
||||
|
||||
storage.getStorageData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', onDataArrived);
|
||||
storage.getStorageData('AdvancedAlgos', 'AAPlatform', 'ecosystem.json', true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(host.codeName + "/" + "competitions", competition.repo, competition.configFile, onDataArrived);
|
||||
storage.getStorageData(host.codeName + "/" + "competitions", competition.repo, competition.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(host.codeName + "/" + "plotters", plotter.repo, plotter.configFile, onDataArrived);
|
||||
storage.getStorageData(host.codeName + "/" + "plotters", plotter.repo, plotter.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -291,7 +291,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(devTeam.codeName + "/" + "bots", bot.repo, bot.configFile, onDataArrived);
|
||||
storage.getStorageData(devTeam.codeName + "/" + "bots", bot.repo, bot.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -354,7 +354,7 @@
|
||||
|
||||
requestsSent++;
|
||||
|
||||
storage.getStorageData(devTeam.codeName + "/" + "plotters", plotter.repo, plotter.configFile, onDataArrived);
|
||||
storage.getStorageData(devTeam.codeName + "/" + "plotters", plotter.repo, plotter.configFile, true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
+6
-2
@@ -17,7 +17,7 @@
|
||||
|
||||
}
|
||||
|
||||
function getStorageData(pOrg, pRepo, pPath, callBackFunction) {
|
||||
function getStorageData(pOrg, pRepo, pPath, saveAtCache, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -72,8 +72,12 @@
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> pRepo = " + pRepo); }
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] Storage -> getStorageData -> onFileReceived -> pPath = " + pPath); }
|
||||
|
||||
storageData.set(pOrg + '.' + pRepo + '.' + pPath, text);
|
||||
if (saveAtCache === true) {
|
||||
|
||||
storageData.set(pOrg + '.' + pRepo + '.' + pPath, text);
|
||||
|
||||
}
|
||||
|
||||
if (err !== null || text === null) {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> getStorageData -> onFileReceived -> Error Received from Storage Library. "); }
|
||||
|
||||
@@ -470,9 +470,9 @@ function onBrowserRequest(request, response) {
|
||||
}
|
||||
botCode.saveBotCode(devTeam, source, repo, path, pData, onResponse);
|
||||
|
||||
function onResponse(err, pResponse) {
|
||||
function onResponse(err) {
|
||||
|
||||
respondWithContent(JSON.stringify(pResponse), response);
|
||||
respondWithContent(JSON.stringify(err), response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -782,7 +782,7 @@ function onBrowserRequest(request, response) {
|
||||
case "Plotters": // This means the plotter folder, not to be confused with the Plotters script!
|
||||
{
|
||||
|
||||
storage.getStorageData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], onDataArrived);
|
||||
storage.getStorageData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
@@ -794,7 +794,7 @@ function onBrowserRequest(request, response) {
|
||||
|
||||
case "PlotterPanels": // This means the PlotterPanels folder, not to be confused with the Plotter Panels scripts!
|
||||
{
|
||||
storage.getStorageData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], onDataArrived);
|
||||
storage.getStorageData(requestParameters[2] + "/" + "plotters", requestParameters[3], requestParameters[4], true, onDataArrived);
|
||||
|
||||
function onDataArrived(pData) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user