Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/cocoindex_code/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ async def _check_file_walk(project_root_str: str) -> DoctorCheckResult:
except FileNotFoundError as e:
return DoctorCheckResult(name="File Walk", ok=False, details=[], errors=[str(e)])

matcher = build_matcher(project_root, ps.include_patterns, ps.exclude_patterns)
matcher = build_matcher(
project_root, ps.include_patterns, ps.exclude_patterns, ps.max_file_size
)

counts_by_ext: dict[str, int] = {}
gitignore_dirs: list[str] = []
Expand Down
23 changes: 23 additions & 0 deletions tests/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,29 @@ def _recv_index_response(conn: Connection) -> tuple[list[IndexProgressUpdate], I
raise AssertionError(f"Unexpected response during indexing: {type(resp).__name__}")


async def test_file_walk_respects_project_max_file_size(tmp_path: Path) -> None:
"""Doctor reports the same capped project files as indexing and grep."""
from cocoindex_code.daemon import _check_file_walk

settings = default_project_settings()
settings.include_patterns = ["**/*.py"]
settings.exclude_patterns = []
settings.max_file_size = 64
save_project_settings(tmp_path, settings)

(tmp_path / "exact.py").write_bytes(b"a" * 64)
(tmp_path / "over.py").write_bytes(b"a" * 65)

capped = await _check_file_walk(str(tmp_path))
assert capped.details[:2] == ["Total matched files: 1", " .py: 1"]

settings.max_file_size = None
save_project_settings(tmp_path, settings)

unlimited = await _check_file_walk(str(tmp_path))
assert unlimited.details[:2] == ["Total matched files: 2", " .py: 2"]


@pytest.fixture(scope="session")
def daemon_project(daemon_sock: str) -> str:
"""Create and index a project once for the session. Returns project_root str."""
Expand Down
Loading