mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 15:30:41 +09:00
Hardened NaN checks, added file read delay for research-sync so factorio has time to finish writing to the file
This commit is contained in:
1 parent
ed9b4bbafa
commit
03511fc240
4 files changed
+47
-33
No files matched your search
@@ -476,17 +476,23 @@ function instanceManagement() {
|
||||
// send file contents to plugin for processing
|
||||
function fileChangeHandler(eventType, filename) {
|
||||
if(filename != null){
|
||||
// get array of lines in file
|
||||
let stuff = fs.readFileSync(instancedirectory + "/script-output/" + filename, "utf8").split("\n");
|
||||
// if you found anything, reset the file
|
||||
if (stuff[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/" + filename, "");
|
||||
}
|
||||
for(let i = 0; i < stuff.length; i++) {
|
||||
if(stuff[i] && !stuff[i].includes('\u0000\u0000')) {
|
||||
plugins[I].scriptOutput(stuff[i]);
|
||||
}
|
||||
}
|
||||
setTimeout(
|
||||
()=>{
|
||||
// get array of lines in file
|
||||
let stuff = fs.readFileSync(instancedirectory + "/script-output/" + filename, "utf8").split("\n");
|
||||
|
||||
// if you found anything, reset the file
|
||||
if (stuff[0]) {
|
||||
fs.writeFileSync(instancedirectory + "/script-output/" + filename, "");
|
||||
}
|
||||
for(let i = 0; i < stuff.length; i++) {
|
||||
if(stuff[i] && !stuff[i].includes('\u0000\u0000')) {
|
||||
plugins[I].scriptOutput(stuff[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
pluginConfig.fileReadDelay || 0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user