Ver código fonte

Merge pull request #8 from burke/native-realpath

Use native realpathSync instead of spawning subprocess per file
(15.6s -> 1.0s for large collections)
Tobi Lutke 4 meses atrás
pai
commit
5b636b2e4c
1 arquivos alterados com 5 adições e 6 exclusões
  1. 5 6
      src/store.ts

+ 5 - 6
src/store.ts

@@ -13,6 +13,7 @@
 
 import { Database } from "bun:sqlite";
 import { Glob } from "bun";
+import { realpathSync } from "node:fs";
 import * as sqliteVec from "sqlite-vec";
 import {
   LlamaCpp,
@@ -116,12 +117,10 @@ export function getPwd(): string {
 
 export function getRealPath(path: string): string {
   try {
-    const result = Bun.spawnSync(["realpath", path]);
-    if (result.success) {
-      return result.stdout.toString().trim();
-    }
-  } catch { }
-  return resolve(path);
+    return realpathSync(path);
+  } catch {
+    return resolve(path);
+  }
 }
 
 // =============================================================================