Recreate instance's required subfolders on startup (#705)

Fixes #698
This commit is contained in:
Daniel authored and GitHub committed 2024-12-09 15:21:59 -08:00
1 parent b093cd136f
commit 485504d885
2 files changed
+5 -6

No files matched your search

+2 -1
View File
@@ -641,6 +641,7 @@ export default class Host extends lib.Link {
} else { } else {
instanceInfo = this.discoveredInstanceInfos.get(instanceId); instanceInfo = this.discoveredInstanceInfos.get(instanceId);
if (instanceInfo) { if (instanceInfo) {
await Instance.populate_folders(instanceInfo.path);
instanceInfo.config.update(config, true, "controller"); instanceInfo.config.update(config, true, "controller");
} else { } else {
@@ -650,7 +651,7 @@ export default class Host extends lib.Link {
let instanceDir = await this._createNewInstanceDir(instanceConfig.get("instance.name")); let instanceDir = await this._createNewInstanceDir(instanceConfig.get("instance.name"));
logger.info(`Creating ${instanceDir}`); logger.info(`Creating ${instanceDir}`);
await Instance.create(instanceDir, this.config.get("host.factorio_directory")); await Instance.populate_folders(instanceDir);
instanceInfo = { instanceInfo = {
path: instanceDir, path: instanceDir,
config: instanceConfig, config: instanceConfig,
+3 -5
View File
@@ -661,14 +661,12 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
/** /**
* Creates a new empty instance directory * Creates a new empty instance directory
* *
* Creates the neccessary files for starting up a new instance into the * Ensures the neccessary files for starting up a new instance into the
* provided instance directory. * provided instance directory are present.
* *
* @param instanceDir - * @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, "script-output"));
await fs.ensureDir(path.join(instanceDir, "saves")); await fs.ensureDir(path.join(instanceDir, "saves"));
} }