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

Function load_change_data

libatomic/src/daemon/services_sync_remote.rs:377–399  ·  view source on GitHub ↗

The local `load_change_data` — the raw on-disk change bytes (the exact bytes that produced the content hash), with the load+serialize fallback.

(repo: &Repository, hash: &Hash)

Source from the content-addressed store, hash-verified

375/// The local `load_change_data` — the raw on-disk change bytes (the exact
376/// bytes that produced the content hash), with the load+serialize fallback.
377fn load_change_data(repo: &Repository, hash: &Hash) -> Result<Bytes, Status> {
378 let change_path = repo.change_store().change_path(hash);
379 if change_path.exists() {
380 let data = std::fs::read(&change_path).map_err(|error| {
381 domain_status(
382 ErrorCode::Repository,
383 format!("Failed to read change file {:?}: {error}", change_path),
384 )
385 })?;
386 return Ok(Bytes::from(data));
387 }
388 let change = repo.load_change(hash).map_err(|_| {
389 domain_status(
390 ErrorCode::Changes,
391 format!("change not found: {}", hash.to_base32()),
392 )
393 })?;
394 let mut buffer = Vec::new();
395 change.serialize(&mut buffer).map_err(|error| {
396 domain_status(ErrorCode::Repository, format!("serialize change: {error}"))
397 })?;
398 Ok(Bytes::from(buffer))
399}
400
401fn load_change_message(repo: &Repository, hash: &Hash) -> Option<String> {
402 repo.load_change(hash)

Callers 1

push_changes_implFunction · 0.70

Calls 7

domain_statusFunction · 0.85
readFunction · 0.50
change_pathMethod · 0.45
change_storeMethod · 0.45
existsMethod · 0.45
load_changeMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected