mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 08:23:12 +09:00
Fix null processing ( again )
This commit is contained in:
1 parent
834fc8cf98
commit
31cfc45e58
1 file changed
+12
-14
+12
-14
@@ -160,7 +160,6 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
let emmiter = new events.EventEmitter();
|
let emmiter = new events.EventEmitter();
|
||||||
editorSpawn.on("exit", async (exit) => {
|
editorSpawn.on("exit", async (exit) => {
|
||||||
const data = await fs.readFile(tmpFile, "utf8");
|
const data = await fs.readFile(tmpFile, "utf8");
|
||||||
let final = [];
|
|
||||||
let splitData = data.split(/\r?\n/);
|
let splitData = data.split(/\r?\n/);
|
||||||
// split on newlines
|
// split on newlines
|
||||||
let filtered = splitData.filter((value) => !(value[0] === "#")).filter((a) => a);
|
let filtered = splitData.filter((value) => !(value[0] === "#")).filter((a) => a);
|
||||||
@@ -173,23 +172,15 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
let part = "";
|
let part = "";
|
||||||
try {
|
try {
|
||||||
part = filtered[index][1].trim();
|
part = filtered[index][1].trim();
|
||||||
|
// it's a string if we can read it
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// if we can't read it, it's a empty field and therefor null
|
||||||
part = "";
|
part = "";
|
||||||
}
|
}
|
||||||
if (part === "null") {
|
|
||||||
print(`Warning: ${finalIndex} has been set to the value null, not the string "null".`);
|
|
||||||
part = "";
|
|
||||||
}
|
|
||||||
final[finalIndex] = part;
|
|
||||||
// trim whitespace and put in final array for processing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let element in final) {
|
|
||||||
if (element in final) {
|
|
||||||
try {
|
try {
|
||||||
await libLink.messages.setMasterConfigField.send(control, {
|
await libLink.messages.setMasterConfigField.send(control, {
|
||||||
field: element,
|
field: finalIndex,
|
||||||
value: final[element],
|
value: part,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
@@ -200,7 +191,14 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
emmiter.emit("dot_on_done");
|
emmiter.emit("dot_on_done");
|
||||||
});
|
});
|
||||||
await events.once(emmiter, "dot_on_done");
|
await events.once(emmiter, "dot_on_done");
|
||||||
await fs.unlink(tmpFile);
|
await fs.unlink(tmpFile, (err) => {
|
||||||
|
if (err) {
|
||||||
|
print("err: temporary file", tmpFile, "could not be deleted.");
|
||||||
|
print("This is not fatal, but they may build up over time if the issue persists.");
|
||||||
|
print("Trace:");
|
||||||
|
print(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user