Merge pull request #866 from Cooldude2606/fix/server-whitelist

Always create a whitelist file so it can be watched for changes
This commit is contained in:
Cooldude2606 authored and GitHub committed 2026-03-10 00:32:19 +00:00
commit eb09413d8b
3 files changed
+42 -2

No files matched your search

+11
View File
@@ -866,6 +866,17 @@ end`.replace(/\r?\n/g, " ");
this.server.writePath("server-whitelist.json"),
JSON.stringify([...this._host.whitelist], null, "\t")
);
} else {
// Always create the whitelist even if unused
// This allows it to be watched for changes without a server restart
try {
// wx will throw an error if the file already exists to prevent overwrite
await fs.writeFile(this.server.writePath("server-whitelist.json"), "\n[]\n", { flag: "wx" });
} catch (err: any) {
if (err.code !== "EEXIST") {
throw err;
}
}
}
await this.syncMods();
+1 -1
View File
@@ -887,7 +887,7 @@ export class FactorioServer extends events.EventEmitter<FactorioServerEvents> {
try {
this._whitelistWatcher = fs.watch(filePath);
} catch (err: any) {
this._logger.error(`Unable to watch whitelist, bidirectional sync will not be available:\n${err}`);
this._logger.warn(`Unable to watch whitelist, bidirectional sync will not be available:\n${err}`);
return;
}