Skip to content

Commit 3b3950c

Browse files
authored
Merge pull request #29490 from storybookjs/valentin/fix-race-condition-during-init
Core: Fix race condition during empty folder init
2 parents f3ba675 + 0d576eb commit 3b3950c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

code/core/src/common/utils/file-cache.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ export class FileSystemCache {
8585
orgOpts: CacheSetOptions | number = {}
8686
): Promise<void> {
8787
const opts: CacheSetOptions = typeof orgOpts === 'number' ? { ttl: orgOpts } : orgOpts;
88+
mkdirSync(this.cache_dir, { recursive: true });
8889
await writeFile(this.generateHash(name), this.parseSetData(name, data, opts), {
8990
encoding: opts.encoding || 'utf8',
9091
});
9192
}
9293

9394
public setSync<T>(name: string, data: T, orgOpts: CacheSetOptions | number = {}): void {
9495
const opts: CacheSetOptions = typeof orgOpts === 'number' ? { ttl: orgOpts } : orgOpts;
96+
mkdirSync(this.cache_dir, { recursive: true });
9597
writeFileSync(this.generateHash(name), this.parseSetData(name, data, opts), {
9698
encoding: opts.encoding || 'utf8',
9799
});

0 commit comments

Comments
 (0)