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

Function manifest_from_pack

libatomic/src/daemon/services_sync_remote.rs:972–1009  ·  view source on GitHub ↗

The local `manifest_from_pack` — one view's manifest reconstructed from the pack's ref + snapshot, with the O(1) set-id cross-check.

(
    pack: &SyncPack,
    name: &str,
    url: &str,
    warnings: &mut Vec<String>,
)

Source from the content-addressed store, hash-verified

970/// The local `manifest_from_pack` — one view's manifest reconstructed from
971/// the pack's ref + snapshot, with the O(1) set-id cross-check.
972fn manifest_from_pack(
973 pack: &SyncPack,
974 name: &str,
975 url: &str,
976 warnings: &mut Vec<String>,
977) -> Result<Option<ViewManifest>, Status> {
978 let Some(target) = pack.refs.iter().find(|r| r.name == name) else {
979 return Ok(None);
980 };
981 let target = target.new_target.clone();
982 let snapshot = pack
983 .objects
984 .iter()
985 .find(|object| object.family == ObjectFamily::View && object.key == target)
986 .and_then(|object| ViewSnapshot::from_bytes(&object.bytes));
987 let Some(snapshot) = snapshot else {
988 return Ok(None);
989 };
990 let manifest = ViewManifest::parse(&snapshot.to_manifest_text(name)).map_err(|error| {
991 sync_error(
992 "fetch",
993 "remote_error",
994 url,
995 format!("Corrupt manifest for view '{name}': {error}"),
996 )
997 })?;
998 let mut fold = SetId::ZERO;
999 for hash in &manifest.changes {
1000 fold = fold.add(hash);
1001 }
1002 if fold.to_base32() != snapshot.own_set_id {
1003 warnings.push(format!(
1004 "Remote view '{name}' snapshot set-id disagrees with its change list; \
1005 the remote object may be inconsistent."
1006 ));
1007 }
1008 Ok(Some(manifest))
1009}
1010
1011/// The local `save_downloaded_change` — deserialize, verify the hash, save.
1012fn save_downloaded_change(repo: &Repository, hash: &Hash, data: Bytes) -> Result<(), String> {

Callers 1

manifest_chain_from_packFunction · 0.70

Calls 8

sync_errorFunction · 0.85
to_manifest_textMethod · 0.80
parseFunction · 0.50
iterMethod · 0.45
cloneMethod · 0.45
addMethod · 0.45
to_base32Method · 0.45
pushMethod · 0.45

Tested by

no test coverage detected