1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-11 09:11:50 +00:00

Fix file writes to non-existent directories

When the game attempts to create the settings file but its directory
does not exist yet, an early error occurs. In reality, there is no way
for the directory to be created without user intervention. This change
makes sure the directory is created before any attempt to write a file
is done. Errors related to directory creation and/or file writes are
still reported as usual.
This commit is contained in:
Даниїл Григор'єв 2025-03-26 22:46:14 +02:00
parent 03bf14f10a
commit ae1cd71d3b
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D

View File

@ -49,6 +49,10 @@ export class FsJobHandler {
}
private async write(file: string, contents: string): Promise<string> {
// The target directory might not exist, ensure it does
const parentDir = path.dirname(file);
await fs.mkdir(parentDir, { recursive: true });
// Backups not implemented yet.
await fs.writeFile(file, contents, {
encoding: "utf-8",