Explorar o código

Merge pull request #253 from jimmynail/fix/skip-unreadable-files

fix: skip unreadable files during indexing instead of crashing
Tobias Lütke hai 2 meses
pai
achega
271feb7791
Modificáronse 1 ficheiros con 9 adicións e 1 borrados
  1. 9 1
      src/qmd.ts

+ 9 - 1
src/qmd.ts

@@ -1452,7 +1452,15 @@ async function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, coll
     const path = handelize(relativeFile); // Normalize path for token-friendliness
     seenPaths.add(path);
 
-    const content = readFileSync(filepath, "utf-8");
+    let content: string;
+    try {
+      content = readFileSync(filepath, "utf-8");
+    } catch (err: any) {
+      // Skip files that can't be read (e.g. iCloud evicted files returning EAGAIN)
+      processed++;
+      progress.set((processed / total) * 100);
+      continue;
+    }
 
     // Skip empty files - nothing useful to index
     if (!content.trim()) {