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,
)
| 455 | /// This replaces the per-object `get_view_ref` + `get_object("views", …)` |
| 456 | /// round-trips: clone reads every view's state from the single `/code` pull. |
| 457 | fn view_manifest_from_pack( |
| 458 | &self, |
| 459 | pack: &SyncPack, |
| 460 | view: &str, |
| 461 | ) -> CliResult<Option<ViewManifest>> { |
| 462 | let target = match pack.refs.iter().find(|r| r.name == view) { |
| 463 | Some(r) => r.new_target.clone(), |
| 464 | None => return Ok(None), |
| 465 | }; |
| 466 | let snapshot = pack |
| 467 | .objects |
| 468 | .iter() |
| 469 | .find(|o| o.family == ObjectFamily::View && o.key == target) |
| 470 | .and_then(|o| ViewSnapshot::from_bytes(&o.bytes)); |
| 471 | let snapshot = match snapshot { |
| 472 | Some(s) => s, |
| 473 | None => return Ok(None), |
| 474 | }; |
| 475 | let manifest = parse_remote_manifest(view, &snapshot.to_manifest_text(view), &self.url)?; |
| 476 | // O(1) producer-integrity cross-check: the snapshot's declared |
| 477 | // `own_set_id` must equal the order-invariant fold of its own change |
| 478 | // list (content addressing guarantees the bytes, not a self-consistent |
| 479 | // producer). |
| 480 | let mut fold = SetId::ZERO; |
| 481 | for h in &manifest.changes { |
| 482 | fold = fold.add(h); |
| 483 | } |
| 484 | if fold.to_base32() != snapshot.own_set_id { |
| 485 | print_warning(&format!( |
| 486 | "Remote view '{view}' snapshot set-id disagrees with its change list; \ |
| 487 | the remote object may be inconsistent." |
| 488 | )); |
| 489 | } |
| 490 | Ok(Some(manifest)) |
| 491 | } |
| 492 | |
| 493 | /// Verify convergence with the order-invariant `SetId`: each applied view's |
| 494 | /// local **effective** set-id must equal the remote's, taken from the server |
no test coverage detected