Fetch and validate one view's manifest from the remote. Returns `Ok(None)` if the remote does not have the view. Reconstruct one view's manifest from a pulled [`SyncPack`]: find its ref target, then its view-snapshot object, and render the manifest text. Returns `Ok(None)` when the pack carries no ref/snapshot for `view`. This replaces the per-object `get_view_ref` + `get_object("views", …)` rou
(
&self,
pack: &SyncPack,
view: &str,
)
| 352 | /// This replaces the per-object `get_view_ref` + `get_object("views", …)` |
| 353 | /// round-trips: clone reads every view's state from the single `/code` pull. |
| 354 | fn view_manifest_from_pack( |
| 355 | &self, |
| 356 | pack: &SyncPack, |
| 357 | view: &str, |
| 358 | ) -> CliResult<Option<ViewManifest>> { |
| 359 | let target = match pack.refs.iter().find(|r| r.name == view) { |
| 360 | Some(r) => r.new_target.clone(), |
| 361 | None => return Ok(None), |
| 362 | }; |
| 363 | let snapshot = pack |
| 364 | .objects |
| 365 | .iter() |
| 366 | .find(|o| o.family == ObjectFamily::View && o.key == target) |
| 367 | .and_then(|o| ViewSnapshot::from_bytes(&o.bytes)); |
| 368 | let snapshot = match snapshot { |
| 369 | Some(s) => s, |
| 370 | None => return Ok(None), |
| 371 | }; |
| 372 | let manifest = parse_remote_manifest(view, &snapshot.to_manifest_text(view), &self.url)?; |
| 373 | // O(1) producer-integrity cross-check: the snapshot's declared |
| 374 | // `own_set_id` must equal the order-invariant fold of its own change |
| 375 | // list (content addressing guarantees the bytes, not a self-consistent |
| 376 | // producer). |
| 377 | let mut fold = SetId::ZERO; |
| 378 | for h in &manifest.changes { |
| 379 | fold = fold.add(h); |
| 380 | } |
| 381 | if fold.to_base32() != snapshot.own_set_id { |
| 382 | print_warning(&format!( |
| 383 | "Remote view '{view}' snapshot set-id disagrees with its change list; \ |
| 384 | the remote object may be inconsistent." |
| 385 | )); |
| 386 | } |
| 387 | Ok(Some(manifest)) |
| 388 | } |
| 389 | |
| 390 | /// Verify convergence with the order-invariant `SetId`: each applied view's |
| 391 | /// local **effective** set-id must equal the remote's, taken from the server |
no test coverage detected