From 485504d88571be4fb75d725969eceefbad27cd65 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 9 Dec 2024 15:21:59 -0800 Subject: [PATCH] Recreate instance's required subfolders on startup (#705) Fixes #698 --- packages/host/src/Host.ts | 3 ++- packages/host/src/Instance.ts | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/host/src/Host.ts b/packages/host/src/Host.ts index 6690d304..0e60d2a1 100644 --- a/packages/host/src/Host.ts +++ b/packages/host/src/Host.ts @@ -641,6 +641,7 @@ export default class Host extends lib.Link { } else { instanceInfo = this.discoveredInstanceInfos.get(instanceId); if (instanceInfo) { + await Instance.populate_folders(instanceInfo.path); instanceInfo.config.update(config, true, "controller"); } else { @@ -650,7 +651,7 @@ export default class Host extends lib.Link { let instanceDir = await this._createNewInstanceDir(instanceConfig.get("instance.name")); logger.info(`Creating ${instanceDir}`); - await Instance.create(instanceDir, this.config.get("host.factorio_directory")); + await Instance.populate_folders(instanceDir); instanceInfo = { path: instanceDir, config: instanceConfig, diff --git a/packages/host/src/Instance.ts b/packages/host/src/Instance.ts index 5fbe09fb..76405277 100644 --- a/packages/host/src/Instance.ts +++ b/packages/host/src/Instance.ts @@ -661,14 +661,12 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " "); /** * Creates a new empty instance directory * - * Creates the neccessary files for starting up a new instance into the - * provided instance directory. + * Ensures the neccessary files for starting up a new instance into the + * provided instance directory are present. * * @param instanceDir - - * Directory to create the new instance into. - * @param factorioDir - Path to factorio installation. */ - static async create(instanceDir: string, factorioDir: string) { + static async populate_folders(instanceDir: string) { await fs.ensureDir(path.join(instanceDir, "script-output")); await fs.ensureDir(path.join(instanceDir, "saves")); }