Skip to content

Commit 271feb7

Browse files
authored
Merge pull request #253 from jimmynail/fix/skip-unreadable-files
fix: skip unreadable files during indexing instead of crashing
2 parents ee08997 + 32cd83b commit 271feb7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/qmd.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,15 @@ async function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, coll
14521452
const path = handelize(relativeFile); // Normalize path for token-friendliness
14531453
seenPaths.add(path);
14541454

1455-
const content = readFileSync(filepath, "utf-8");
1455+
let content: string;
1456+
try {
1457+
content = readFileSync(filepath, "utf-8");
1458+
} catch (err: any) {
1459+
// Skip files that can't be read (e.g. iCloud evicted files returning EAGAIN)
1460+
processed++;
1461+
progress.set((processed / total) * 100);
1462+
continue;
1463+
}
14561464

14571465
// Skip empty files - nothing useful to index
14581466
if (!content.trim()) {

0 commit comments

Comments
 (0)