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>,
)
| 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. |
| 972 | fn 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. |
| 1012 | fn save_downloaded_change(repo: &Repository, hash: &Hash, data: Bytes) -> Result<(), String> { |
no test coverage detected