Serve side, once a sandbox's change `hash` has landed on `view`: the view's skeleton for the sandbox's cache, and — as a pull does for the files it writes — the vault files the change touched, indexed into the repository's (repository-wide) vault. One render of the view serves both.
(
&self,
view: &str,
hash: &Hash,
)
| 1019 | /// the repository's (repository-wide) vault. One render of the view |
| 1020 | /// serves both. |
| 1021 | pub fn after_sandbox_submit( |
| 1022 | &self, |
| 1023 | view: &str, |
| 1024 | hash: &Hash, |
| 1025 | ) -> Result<SandboxSkeleton, RepositoryError> { |
| 1026 | let change = self.load_change(hash)?; |
| 1027 | let vault_paths: BTreeSet<String> = change |
| 1028 | .hunks() |
| 1029 | .iter() |
| 1030 | .filter_map(|h| h.path()) |
| 1031 | .chain(change.file_ops().iter().map(|ops| ops.path())) |
| 1032 | .filter(|p| p.starts_with(".vault/") && p.ends_with(".md")) |
| 1033 | .map(str::to_string) |
| 1034 | .collect(); |
| 1035 | let mut live = std::collections::BTreeMap::new(); |
| 1036 | let mut files = std::collections::BTreeMap::new(); |
| 1037 | self.materialize_view_entries::<()>(view, |entry| { |
| 1038 | live.insert(entry.inode, entry.path.clone()); |
| 1039 | if vault_paths.contains(&entry.path) { |
| 1040 | files.insert( |
| 1041 | entry.path, |
| 1042 | String::from_utf8_lossy(&entry.content).into_owned(), |
| 1043 | ); |
| 1044 | } |
| 1045 | Ok(()) |
| 1046 | })? |
| 1047 | .map_err(|()| RepositoryError::Output("unreachable".to_string()))?; |
| 1048 | if !vault_paths.is_empty() && self.has_vault()? { |
| 1049 | let rows: Vec<(String, Option<String>)> = vault_paths |
| 1050 | .iter() |
| 1051 | .map(|p| (p[".vault/".len()..].to_string(), files.remove(p))) |
| 1052 | .collect(); |
| 1053 | self.vault_record_files(&rows)?; |
| 1054 | } |
| 1055 | self.export_sandbox_skeleton(view, &live) |
| 1056 | } |
| 1057 | |
| 1058 | /// Serve side: publish a remote sandbox's checkpoint — if everything its |
| 1059 | /// provenance explains is on `view`. The graph arrives serialized, so |