fix(vfs): resolve two critical VFS bugs causing directory listing corruption
Bug 1: verbCountsByType optimization skipping requested verb types - After restart, stale statistics could cause VerbType.Contains to be skipped - readdir() would return empty/incomplete results - Fixed by never skipping verb types explicitly requested in filter - Added fast path for sourceId + verbType combo (common VFS pattern) - Save statistics on first entity of each type (not just every 100th) Bug 2: UnifiedCache not invalidated on path deletion - rmdir() cleared local caches but NOT the global UnifiedCache - When folder recreated, resolve() returned stale entity ID - Caused "Source entity not found" errors - Fixed by adding deleteByPrefix() to UnifiedCache - Fixed invalidatePath() to also clear UnifiedCache entries Files modified: - src/storage/baseStorage.ts (verbCountsByType fix + fast path) - src/utils/unifiedCache.ts (deleteByPrefix method) - src/vfs/PathResolver.ts (cache invalidation fix) Tests added: - tests/unit/storage/vfs-mkdir-bug.test.ts (7 tests) Reported by: Soulcraft Workshop team 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1da6048245
commit
2ba69eccdc
4 changed files with 375 additions and 13 deletions
|
|
@ -415,6 +415,24 @@ export class UnifiedCache {
|
|||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all items with keys starting with the given prefix
|
||||
* v6.2.9: Added for VFS cache invalidation (fixes stale parent ID bug)
|
||||
* @param prefix - The key prefix to match
|
||||
* @returns Number of items deleted
|
||||
*/
|
||||
deleteByPrefix(prefix: string): number {
|
||||
let deleted = 0
|
||||
for (const [key, item] of this.cache) {
|
||||
if (key.startsWith(prefix)) {
|
||||
this.currentSize -= item.size
|
||||
this.cache.delete(key)
|
||||
deleted++
|
||||
}
|
||||
}
|
||||
return deleted
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear cache or specific type
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue