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

Function write_head_map

atomic-repository/src/repository/anchor.rs:349–370  ·  view source on GitHub ↗
(
    root: &Path,
    mappings: &BTreeMap<String, HeadMapEntry>,
)

Source from the content-addressed store, hash-verified

347}
348
349fn write_head_map(
350 root: &Path,
351 mappings: &BTreeMap<String, HeadMapEntry>,
352) -> Result<(), RepositoryError> {
353 let path = root.join(HEAD_MAP_RELATIVE);
354 if let Some(parent) = path.parent() {
355 fs::create_dir_all(parent).map_err(|error| RepositoryError::InvalidRepository {
356 reason: format!(
357 "cannot create shim directory '{}': {error}",
358 parent.display()
359 ),
360 })?;
361 }
362 let wire = HeadMapWire {
363 version: 1,
364 mappings: mappings.clone(),
365 };
366 let mut bytes = serde_json::to_vec_pretty(&wire)
367 .map_err(|error| RepositoryError::Serialization(error.to_string()))?;
368 bytes.push(b'\n');
369 atomic_write(&root.join(HEAD_MAP_RELATIVE), &bytes)
370}
371
372fn atomic_write(path: &Path, bytes: &[u8]) -> Result<(), RepositoryError> {
373 let parent = path

Calls 4

atomic_writeFunction · 0.85
parentMethod · 0.80
cloneMethod · 0.45
pushMethod · 0.45