early config.uploadModsToMaster check

Move check to start of function for config.uploadModsToMaster. When disabled, write one log line instead of one log line per mod.
This commit is contained in:
survaaki authored and GitHub committed 2019-11-21 16:29:36 +10:00
1 parent 76cca59807
commit 909e7d5ad6
1 file changed
+4 -4
+4 -4
View File
@@ -737,6 +737,7 @@ async function instanceManagement(instanceconfig) {
setTimeout(function(){hashMods(instance, uploadMods)}, 5000); setTimeout(function(){hashMods(instance, uploadMods)}, 5000);
function uploadMods(modHashes) { function uploadMods(modHashes) {
if (config.uploadModsToMaster) {
// [{modName:string,hash:string}, ... ] // [{modName:string,hash:string}, ... ]
for(let i=0;i<modHashes.length;i++){ for(let i=0;i<modHashes.length;i++){
let payload = { let payload = {
@@ -749,7 +750,6 @@ async function instanceManagement(instanceconfig) {
console.log("master has mod "+modHashes[i].modName); console.log("master has mod "+modHashes[i].modName);
} else if (response && body && typeof body == "string") { } else if (response && body && typeof body == "string") {
let mod = response.body; let mod = response.body;
if(config.uploadModsToMaster){
console.log("Sending mod: " + mod); console.log("Sending mod: " + mod);
// Send mods master says it wants // Send mods master says it wants
// response.body is a string which is a modName.zip // response.body is a string which is a modName.zip
@@ -766,12 +766,12 @@ async function instanceManagement(instanceconfig) {
}); });
var form = req.form(); var form = req.form();
form.append('file', fs.createReadStream(config.instanceDirectory+"/"+instance+"/mods/"+mod)); form.append('file', fs.createReadStream(config.instanceDirectory+"/"+instance+"/mods/"+mod));
} else {
console.log("Not sending mod: " + mod + " to master because config.uploadModsToMaster is not enabled")
}
} }
}); });
} }
} else {
console.log("Bypassing sending mods to master because config.uploadModsToMaster is not enabled")
}
} }
} // END OF INSTANCE START --------------------------------------------------------------------- } // END OF INSTANCE START ---------------------------------------------------------------------