MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / build_content_index

Function build_content_index

atomic-repository/src/content_search.rs:29–53  ·  view source on GitHub ↗

Build (or rebuild) the content search index for the repository. Indexes files in the working copy while respecting `.gitignore`, `.ignore`, `.atomicignore` (and the global ignore file), and skipping Atomic-internal directories (`.atomic`, `.git`, `.vault`). The index is stored at `.atomic/content-index/`. Discovery is owned here rather than delegated to syntext's `Index::build`: syntext's walker

(repo_root: &Path)

Source from the content-addressed store, hash-verified

27/// handle still releasing its flock) are retried with backoff; only a
28/// persistent conflict surfaces as an error.
29pub fn build_content_index(repo_root: &Path) -> Result<(), ContentSearchError> {
30 with_lock_retry(|| {
31 let config = content_config(repo_root);
32
33 let (files, _skips) = syntext::index::walk::enumerate_files(&config)?;
34 let ignore_rules = crate::ignore::IgnoreRules::load_for_enrichment(repo_root);
35 let records: Vec<ExternalFileRecord> = files
36 .into_iter()
37 .filter(|(_absolute, relative, _size)| {
38 !crate::ignore::is_enrichment_internal(relative)
39 && !ignore_rules.is_ignored(relative, false)
40 })
41 .map(
42 |(absolute_path, relative_path, size_bytes)| ExternalFileRecord {
43 absolute_path,
44 relative_path,
45 size_bytes,
46 },
47 )
48 .collect();
49
50 let _index = Index::build_from_file_records(config, records)?;
51 Ok(())
52 })
53}
54
55/// Incrementally update the content index after file changes.
56///

Calls 5

with_lock_retryFunction · 0.85
content_configFunction · 0.85
is_enrichment_internalFunction · 0.85
into_iterMethod · 0.45
is_ignoredMethod · 0.45