Skip to content
Merged
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
12 changes: 4 additions & 8 deletions src/ingest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ export async function ingestPath(
return;
}

result.filesProcessed++;

// Update counter immediately for every file (BEFORE MAX_FILE_SIZE gate — skipped files still advance the counter)
options?.progressCallback?.({ current: i + 1, total: walkedFiles.length });
options?.progressCallback?.({ current: result.filesProcessed, total: walkedFiles.length });

if (fileStats.size > MAX_FILE_SIZE) {
const msg = `Skipped (too large, ${(fileStats.size / 1024 / 1024).toFixed(1)}MB): ${filePath}`;
Expand All @@ -212,7 +214,7 @@ export async function ingestPath(
// Only show filename in progress if the file takes longer than 3s
let slowFileTimer: ReturnType<typeof setTimeout> | undefined;
slowFileTimer = setTimeout(() => {
options?.progressCallback?.({ current: i + 1, total: walkedFiles.length, currentFile: filePath, currentFileSize: fileStats.size });
options?.progressCallback?.({ current: result.filesProcessed, total: walkedFiles.length, currentFile: filePath, currentFileSize: fileStats.size });
}, SLOW_FILE_DISPLAY_MS) as unknown as ReturnType<typeof setTimeout>;

// Read file as raw buffer — binary-safe hashing (avoids encoding issues)
Expand All @@ -221,7 +223,6 @@ export async function ingestPath(
buf = await Bun.file(filePath).arrayBuffer();
} catch (err) {
result.errors.push(`Failed to read ${filePath}: ${String(err)}`);
result.filesProcessed++;
return;
}

Expand Down Expand Up @@ -251,8 +252,6 @@ export async function ingestPath(
if (existing && existing.content_hash === contentHash) {
db.exec(`RELEASE SAVEPOINT ${spFile}`);
result.filesSkipped++;
result.filesProcessed++;
options?.progressCallback?.({ current: result.filesProcessed, total: walkedFiles.length });
return;
}
}
Expand Down Expand Up @@ -382,7 +381,6 @@ export async function ingestPath(
}

if (fileFailed) {
result.filesProcessed++;
return;
}

Expand All @@ -399,7 +397,6 @@ export async function ingestPath(
}

if (fileFailed) {
result.filesProcessed++;
return;
}

Expand Down Expand Up @@ -440,7 +437,6 @@ export async function ingestPath(
db.exec(`RELEASE SAVEPOINT ${spFile}`);

result.filesIndexed++;
result.filesProcessed++;
if (slowFileTimer) clearTimeout(slowFileTimer);
options?.progressCallback?.({ current: result.filesProcessed, total: walkedFiles.length });

Expand Down
Loading