mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix(files): skip broken symlinks during directory scans
This commit is contained in:
1 parent
074c7d178e
commit
53a70d8545
2 files changed
+80
-4
No files matched your search
@@ -135,13 +135,23 @@ export async function listDirectory(dirPath: string): Promise<Array<{
|
||||
if (entry.name === '.' || entry.name === '..') continue
|
||||
|
||||
const entryPath = path.join(fullPath, entry.name)
|
||||
const stats = await fs.stat(entryPath)
|
||||
let stats: Awaited<ReturnType<typeof fs.stat>>
|
||||
try {
|
||||
stats = await fs.stat(entryPath)
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException).code
|
||||
if (code === 'ENOENT' || code === 'ENOTDIR' || code === 'ELOOP') {
|
||||
logger.warn(`Skipping unresolvable directory entry ${entryPath}:`, error)
|
||||
continue
|
||||
}
|
||||
throw error
|
||||
}
|
||||
|
||||
result.push({
|
||||
name: entry.name,
|
||||
path: entryPath,
|
||||
isDirectory: entry.isDirectory(),
|
||||
size: entry.isDirectory() ? 0 : stats.size,
|
||||
isDirectory: stats.isDirectory(),
|
||||
size: stats.isDirectory() ? 0 : stats.size,
|
||||
lastModified: stats.mtime
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user