Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / Source
Diff by blob SHA
Only new and changed files are parsed and embedded. Unchanged files just move their commit pointer.
PINNED SOURCE Copied from the repository at this commit. Source, not an execution.
PHAROS at 975a38dMIT license
CodeIndexer._syncbackend/app/codeintel/indexer.py, lines 245–289Open source
def _sync(self, repo_id, ref: RepoRef, checkout: Checkout, stats: IndexStats, *, rewrite_all: bool) -> None: existing = { path: (rid, sha, cov) for rid, path, sha, cov in self.db.execute( select(Resource.id, Resource.identifier, Resource.content_sha, Resource.coverage).where( Resource.repository_id == repo_id ) ) } wanted: dict[str, TreeEntry] = {} for entry in checkout.list_files(): stats.files_tracked += 1 reason = self._skip_reason(entry) if reason: stats.skipped[reason] += 1 continue if len(wanted) >= self.max_files: stats.skipped["max_files_exceeded"] += 1 continue wanted[entry.path] = entry deleted = [existing[p][0] for p in existing if p not in wanted] changed: list[TreeEntry] = [] unchanged: list[tuple[str, str]] = [] # (resource_id, old_commit) for path, entry in wanted.items(): prev = existing.get(path) if prev is None or rewrite_all or prev[1] != entry.blob_sha: changed.append(entry) else: unchanged.append((prev[0], prev[2])) if deleted: self._delete_resources(deleted) stats.files_deleted = len(deleted) self.db.commit() self._repoint_unchanged(repo_id, unchanged, checkout.commit) stats.files_unchanged = len(unchanged) self.db.commit() for i in range(0, len(changed), FILE_BATCH): self._index_batch(repo_id, ref, checkout, changed[i : i + FILE_BATCH], existing, stats) self.db.commit() self.heartbeat()Where this comes from
- Commit
975a38d5d17839c26ee219295a5be6ac66b6d910- File
backend/app/codeintel/indexer.py- Lines
- 245–289
- Git blob
e8fdfa7b5545e821f7649d68cfadd2aae85b89d0- License
- MIT, © 2024–2026 Pharos Contributors. Notice
Read it on GitHub at this commit
Check it yourself
From a clone of the repository, the first command prints the blob above and the second prints these lines.
git rev-parse 975a38d:backend/app/codeintel/indexer.py
git show 975a38d:backend/app/codeintel/indexer.py | sed -n '245,289p'