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:
parent
03bf14f10a
commit
ae1cd71d3b
@ -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",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user