Skip to main content

upsert_reference_cache_v2_with_report

Function upsert_reference_cache_v2_with_report 

Source
pub fn upsert_reference_cache_v2_with_report(
    config: &FoundryConfig,
    build: &CachedBuild,
    changed_abs_paths: &[String],
) -> Result<CacheSaveReport, String>
Expand description

Incrementally upsert v2 cache shards for changed files, serializing global metadata (path_to_abs, id_to_path_map, external_refs) from the merged in-memory CachedBuild (root-key entry in ast_cache).

This ensures the disk cache always mirrors the authoritative in-memory state, which has correct globally-remapped file IDs from merge_scoped_cached_build. Only file shards for changed_abs_paths are rewritten (the incremental fast-path); all other shards are preserved.

The full-project reconcile (save_reference_cache_with_report) is still the canonical full save; this function bridges the gap between saves so that a restart can warm-start from a reasonably up-to-date cache.