Skip to content

Commit

Permalink
Core: Fix race condition during empty folder init
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Oct 30, 2024
1 parent 40c87dd commit 0d576eb
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 0d576eb

Please sign in to comment.