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

Method materialize_prefix

atomic-repository/src/repository/materialize.rs:2426–2463  ·  view source on GitHub ↗

Materialize the working copy for a specific prefix only. This is useful for partial updates when you only want to sync a subset of files. # Arguments `working_copy` - The validated physical working-copy identity `prefix` - Path prefix to materialize (e.g., "src/") # Returns Statistics about the materialize operation.

(
        &self,
        working_copy: WorkingCopyId,
        prefix: &str,
    )

Source from the content-addressed store, hash-verified

2424 ///
2425 /// Statistics about the materialize operation.
2426 pub fn materialize_prefix(
2427 &self,
2428 working_copy: WorkingCopyId,
2429 prefix: &str,
2430 ) -> Result<MaterializeResult, RepositoryError> {
2431 self.validate_working_copy(working_copy)?;
2432 let view_name = self.desired_view_name(working_copy)?;
2433 let txn = self
2434 .pristine
2435 .read_txn()
2436 .map_err(|e| RepositoryError::Database(e.to_string()))?;
2437 let view = txn
2438 .get_view(&view_name)
2439 .map_err(|e| RepositoryError::Database(e.to_string()))?
2440 .ok_or_else(|| RepositoryError::ViewNotFound {
2441 name: view_name.clone(),
2442 })?;
2443 let visibility = graph_visibility_closure(&txn, &view)?;
2444 let projection = self.project_tree_for_visibility(&txn, &visibility)?;
2445 let mut paths: HashSet<String> = projection
2446 .present
2447 .keys()
2448 .chain(projection.absent_metadata.keys())
2449 .chain(projection.name_conflicts.keys())
2450 .filter(|path| path.starts_with(prefix))
2451 .cloned()
2452 .collect();
2453 for path in projection.present.keys() {
2454 if prefix
2455 .strip_prefix(path)
2456 .is_some_and(|suffix| suffix.starts_with('/'))
2457 {
2458 paths.insert(path.clone());
2459 }
2460 }
2461 drop(txn);
2462 self.materialize_parallel(working_copy, Some(paths))
2463 }
2464}
2465
2466/// One entry of a view's tree, rendered in memory by

Callers

nothing calls this directly

Calls 11

graph_visibility_closureFunction · 0.85
validate_working_copyMethod · 0.80
desired_view_nameMethod · 0.80
read_txnMethod · 0.80
keysMethod · 0.80
get_viewMethod · 0.45
cloneMethod · 0.45
collectMethod · 0.45
insertMethod · 0.45
materialize_parallelMethod · 0.45

Tested by

no test coverage detected