Skip to content

Commit fc17c5f

Browse files
committed
fix(indexing): track total_files separately from total_functions
- Add tracked_total_files captured from progress callback via nonlocal - Use total_files for repo_manager.update_file_count() and IndexingStats.files_processed - Keep total_functions for functions_indexed and metrics.record_indexing() - For incremental: use repo's existing file_count or re-analyze if missing
1 parent b40eb3a commit fc17c5f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

backend/routes/repos.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,26 @@ async def _run_async_indexing(
254254
last_commit
255255
)
256256
index_type = "incremental"
257+
# For incremental, get file count from repo or analyze
258+
total_files = repo.get("file_count", 0)
259+
if not total_files:
260+
analysis = repo_validator.analyze_repo(repo["local_path"])
261+
total_files = analysis.file_count if analysis and analysis.success else 0
257262
else:
258263
logger.info("Async FULL indexing with progress", repo_id=repo_id)
259264

265+
# Track total_files from progress callback
266+
tracked_total_files = 0
267+
260268
# Progress callback that publishes to Redis
261269
async def progress_callback(
262270
files_processed: int,
263271
functions_found: int,
264272
total_files: int,
265273
current_file: str = None
266274
):
275+
nonlocal tracked_total_files
276+
tracked_total_files = total_files
267277
if publisher:
268278
publisher.publish_progress(
269279
repo_id,
@@ -278,14 +288,15 @@ async def progress_callback(
278288
repo["local_path"],
279289
progress_callback
280290
)
291+
total_files = tracked_total_files
281292
index_type = "full"
282293

283294
# Update metadata
284295
git_repo = git.Repo(repo["local_path"])
285296
current_commit = git_repo.head.commit.hexsha
286297

287298
repo_manager.update_status(repo_id, "indexed")
288-
repo_manager.update_file_count(repo_id, total_functions)
299+
repo_manager.update_file_count(repo_id, total_files)
289300
repo_manager.update_last_commit(repo_id, current_commit)
290301

291302
duration = time.time() - start_time
@@ -297,7 +308,7 @@ async def progress_callback(
297308
repo_id,
298309
repo_id,
299310
IndexingStats(
300-
files_processed=total_functions,
311+
files_processed=total_files,
301312
functions_indexed=total_functions,
302313
indexing_time_seconds=duration
303314
)

0 commit comments

Comments
 (0)