mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
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:
1 parent
76cca59807
commit
909e7d5ad6
1 file changed
+17
-17
@@ -737,19 +737,19 @@ async function instanceManagement(instanceconfig) {
|
|||||||
|
|
||||||
setTimeout(function(){hashMods(instance, uploadMods)}, 5000);
|
setTimeout(function(){hashMods(instance, uploadMods)}, 5000);
|
||||||
function uploadMods(modHashes) {
|
function uploadMods(modHashes) {
|
||||||
// [{modName:string,hash:string}, ... ]
|
if (config.uploadModsToMaster) {
|
||||||
for(let i=0;i<modHashes.length;i++){
|
// [{modName:string,hash:string}, ... ]
|
||||||
let payload = {
|
for(let i=0;i<modHashes.length;i++){
|
||||||
modName: modHashes[i].modName,
|
let payload = {
|
||||||
hash: modHashes[i].hash,
|
modName: modHashes[i].modName,
|
||||||
};
|
hash: modHashes[i].hash,
|
||||||
needle.post(config.masterIP + ":" + config.masterPort + '/api/checkMod', payload, needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
};
|
||||||
if(err) console.error("Unable to contact master server /api/checkMod! Please check your config.json.");
|
needle.post(config.masterIP + ":" + config.masterPort + '/api/checkMod', payload, needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
||||||
if(response && body && body == "found") {
|
if(err) console.error("Unable to contact master server /api/checkMod! Please check your config.json.");
|
||||||
console.log("master has mod "+modHashes[i].modName);
|
if(response && body && body == "found") {
|
||||||
} else if (response && body && typeof body == "string") {
|
console.log("master has mod "+modHashes[i].modName);
|
||||||
let mod = response.body;
|
} else if (response && body && typeof body == "string") {
|
||||||
if(config.uploadModsToMaster){
|
let mod = response.body;
|
||||||
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,11 +766,11 @@ 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 ---------------------------------------------------------------------
|
||||||
|
|||||||
Reference in new issue
Block a user