Merge pull request #8 from burke/native-realpath
Use native realpathSync instead of spawning subprocess per file (15.6s -> 1.0s for large collections)
This commit is contained in:
commit
5b636b2e4c
11
src/store.ts
11
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);
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Loading…
Reference in New Issue
Block a user