From 0d576eb07b753ac2d550db047311e369e1664fcd Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 30 Oct 2024 16:50:31 +0100 Subject: [PATCH] Core: Fix race condition during empty folder init --- code/core/src/common/utils/file-cache.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index 590ddf60d608..d3ee7dd4ecac 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -85,6 +85,7 @@ export class FileSystemCache { orgOpts: CacheSetOptions | number = {} ): Promise { const opts: CacheSetOptions = typeof orgOpts === 'number' ? { ttl: orgOpts } : orgOpts; + mkdirSync(this.cache_dir, { recursive: true }); await writeFile(this.generateHash(name), this.parseSetData(name, data, opts), { encoding: opts.encoding || 'utf8', }); @@ -92,6 +93,7 @@ export class FileSystemCache { public setSync(name: string, data: T, orgOpts: CacheSetOptions | number = {}): void { const opts: CacheSetOptions = typeof orgOpts === 'number' ? { ttl: orgOpts } : orgOpts; + mkdirSync(this.cache_dir, { recursive: true }); writeFileSync(this.generateHash(name), this.parseSetData(name, data, opts), { encoding: opts.encoding || 'utf8', });