mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
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:
3 files changed
+42
-2
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user