fix(vfs): correct createdAt access in initializeRoot()
- v4.5.3: Fix root selection when multiple roots exist
- brain.find() returns Result[] which has entity.createdAt, not top-level createdAt
- Changed from (a as any).createdAt to a.entity?.createdAt
- Ensures oldest root is selected (most likely to have VFS files)
- Fixes Workshop team bug where VFS files exist but readdir('/') returns empty
Related: v4.5.2 tried to fix field name but accessed wrong object level
This commit is contained in:
parent
dc34c309ce
commit
9f649ff396
1 changed files with 4 additions and 3 deletions
|
|
@ -177,10 +177,11 @@ export class VirtualFileSystem implements IVirtualFileSystem {
|
|||
console.warn(`⚠️ Found ${existing.length} root entities! Using first one, consider cleanup.`)
|
||||
|
||||
// Sort by creation time - use oldest root (most likely to have children)
|
||||
// v4.5.2: FIX - createdAt is at entity level, not metadata level!
|
||||
// v4.5.3: FIX - createdAt is in entity object, not at Result level!
|
||||
// brain.find() returns Result[], which has entity.createdAt, not top-level createdAt
|
||||
existing.sort((a, b) => {
|
||||
const aTime = (a as any).createdAt || a.metadata?.modified || 0
|
||||
const bTime = (b as any).createdAt || b.metadata?.modified || 0
|
||||
const aTime = a.entity?.createdAt || a.metadata?.modified || 0
|
||||
const bTime = b.entity?.createdAt || b.metadata?.modified || 0
|
||||
return aTime - bTime
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue