Add lock file for configs

This commit is contained in:
Cooldude2606 committed 2026-01-07 01:20:40 +00:00
1 parent 00cf0f59ec
commit bccb6527a7
9 files changed
+361 -18

No files matched your search

+5 -1
View File
@@ -169,6 +169,7 @@ async function startHost() {
let hostConfig;
const hostConfigPath = args.config;
const hostConfigLock = new lib.LockFile(`${hostConfigPath}.lock`);
logger.info(`Loading config from ${hostConfigPath}`);
try {
hostConfig = await lib.HostConfig.fromFile("host", hostConfigPath);
@@ -186,10 +187,13 @@ async function startHost() {
hostConfig.set("host.version", version); // Allows tracking last loaded version
if (command === "config") {
await lib.handleConfigCommand(args, hostConfig);
await lib.handleConfigCommand(args, hostConfig, hostConfigLock);
return;
}
// From this point on the host should run
await hostConfigLock.acquire();
// If we get here the command was run
await fs.ensureDir(hostConfig.get("host.instances_directory"));
await fs.ensureDir(hostConfig.get("host.mods_directory"));