Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/qmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Database } from "bun:sqlite";
import { Glob, $ } from "bun";
import { parseArgs } from "util";
import { readFileSync, statSync } from "fs";
import * as sqliteVec from "sqlite-vec";
import {
getPwd,
Expand Down Expand Up @@ -281,7 +282,7 @@ function showStatus(): void {
// Index size
let indexSize = 0;
try {
const stat = Bun.file(dbPath).size;
const stat = statSync(dbPath).size;
indexSize = stat;
} catch { }

Expand Down Expand Up @@ -1401,7 +1402,7 @@ async function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, coll
const path = handelize(relativeFile); // Normalize path for token-friendliness
seenPaths.add(path);

const content = await Bun.file(filepath).text();
const content = readFileSync(filepath, "utf-8");

// Skip empty files - nothing useful to index
if (!content.trim()) {
Expand All @@ -1427,7 +1428,7 @@ async function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, coll
} else {
// Content changed - insert new content hash and update document
insertContent(db, hash, content, now);
const stat = await Bun.file(filepath).stat();
const stat = statSync(filepath);
updateDocument(db, existing.id, title, hash,
stat ? new Date(stat.mtime).toISOString() : now);
updated++;
Expand All @@ -1436,7 +1437,7 @@ async function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, coll
// New document - insert content and document
indexed++;
insertContent(db, hash, content, now);
const stat = await Bun.file(filepath).stat();
const stat = statSync(filepath);
insertDocument(db, collectionName, path, title, hash,
stat ? new Date(stat.birthtime).toISOString() : now,
stat ? new Date(stat.mtime).toISOString() : now);
Expand Down
4 changes: 2 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { Database } from "bun:sqlite";
import { Glob } from "bun";
import { realpathSync } from "node:fs";
import { realpathSync, statSync } from "node:fs";
import * as sqliteVec from "sqlite-vec";
import {
LlamaCpp,
Expand Down Expand Up @@ -427,7 +427,7 @@ function setSQLiteFromBrewPrefixEnv(): void {

for (const candidate of candidates) {
try {
if (Bun.file(candidate).size > 0) {
if (statSync(candidate).size > 0) {
Database.setCustomSQLite(candidate);
return;
}
Expand Down