Skip to content

Commit 92e529a

Browse files
committed
Remove too aggressive stat cache
1 parent 73694e8 commit 92e529a

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "just-bash",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"description": "A simulated bash environment with virtual filesystem",
55
"repository": {
66
"type": "git",

src/fs/overlay-fs/overlay-fs.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ export class OverlayFs implements IFileSystem {
7676
private readonly readOnly: boolean;
7777
private readonly memory: Map<string, MemoryEntry> = new Map();
7878
private readonly deleted: Set<string> = new Set();
79-
// Cache stat results from real filesystem (files don't change during operation)
80-
private readonly statCache: Map<string, FsStat> = new Map();
81-
private readonly lstatCache: Map<string, FsStat> = new Map();
8279

8380
constructor(options: OverlayFsOptions) {
8481
// Resolve to absolute path
@@ -496,25 +493,16 @@ export class OverlayFs implements IFileSystem {
496493
throw new Error(`ENOENT: no such file or directory, stat '${path}'`);
497494
}
498495

499-
// Check stat cache first (files on disk don't change during operation)
500-
const cached = this.statCache.get(realPath);
501-
if (cached) {
502-
return cached;
503-
}
504-
505496
try {
506497
const stat = await fs.promises.stat(realPath);
507-
const result: FsStat = {
498+
return {
508499
isFile: stat.isFile(),
509500
isDirectory: stat.isDirectory(),
510501
isSymbolicLink: false,
511502
mode: stat.mode,
512503
size: stat.size,
513504
mtime: stat.mtime,
514505
};
515-
// Cache the result
516-
this.statCache.set(realPath, result);
517-
return result;
518506
} catch (e) {
519507
if ((e as NodeJS.ErrnoException).code === "ENOENT") {
520508
throw new Error(`ENOENT: no such file or directory, stat '${path}'`);
@@ -565,25 +553,16 @@ export class OverlayFs implements IFileSystem {
565553
throw new Error(`ENOENT: no such file or directory, lstat '${path}'`);
566554
}
567555

568-
// Check lstat cache first
569-
const cached = this.lstatCache.get(realPath);
570-
if (cached) {
571-
return cached;
572-
}
573-
574556
try {
575557
const stat = await fs.promises.lstat(realPath);
576-
const result: FsStat = {
558+
return {
577559
isFile: stat.isFile(),
578560
isDirectory: stat.isDirectory(),
579561
isSymbolicLink: stat.isSymbolicLink(),
580562
mode: stat.mode,
581563
size: stat.size,
582564
mtime: stat.mtime,
583565
};
584-
// Cache the result
585-
this.lstatCache.set(realPath, result);
586-
return result;
587566
} catch (e) {
588567
if ((e as NodeJS.ErrnoException).code === "ENOENT") {
589568
throw new Error(`ENOENT: no such file or directory, lstat '${path}'`);

0 commit comments

Comments
 (0)