Skip to content

Commit

Permalink
Merge pull request #29490 from storybookjs/valentin/fix-race-conditio…
Browse files Browse the repository at this point in the history
…n-during-init

Core: Fix race condition during empty folder init
  • Loading branch information
kasperpeulen authored Oct 30, 2024
2 parents f3ba675 + 0d576eb commit 3b3950c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions code/core/src/common/utils/file-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ export class FileSystemCache {
orgOpts: CacheSetOptions | number = {}
): Promise<void> {
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',
});
}

public setSync<T>(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',
});
Expand Down

0 comments on commit 3b3950c

Please sign in to comment.