The view exists — and, for a grant that recorded the view's id, it is still the view the grant was issued for (deleting a view and recreating its name does not revive a grant).
(
repo: &Repository,
caller: Option<&SandboxCaller>,
view: &str,
)
| 144 | /// still the view the grant was issued for (deleting a view and recreating |
| 145 | /// its name does not revive a grant). |
| 146 | fn check_view( |
| 147 | repo: &Repository, |
| 148 | caller: Option<&SandboxCaller>, |
| 149 | view: &str, |
| 150 | ) -> Result<u64, Status> { |
| 151 | let txn = repo |
| 152 | .pristine() |
| 153 | .read_txn() |
| 154 | .map_err(|e| domain_status(ErrorCode::Repository, e.to_string()))?; |
| 155 | let state = txn |
| 156 | .get_view(view) |
| 157 | .map_err(|e| domain_status(ErrorCode::Repository, e.to_string()))? |
| 158 | .ok_or_else(|| domain_status(ErrorCode::NotFound, format!("no view '{view}'")))?; |
| 159 | if let Some(expected) = caller.and_then(|c| c.grant.view_id) { |
| 160 | if expected != state.id { |
| 161 | return Err(domain_status( |
| 162 | ErrorCode::Forbidden, |
| 163 | format!("view '{view}' is not the view this sandbox's grant was issued for"), |
| 164 | )); |
| 165 | } |
| 166 | } |
| 167 | Ok(state.id) |
| 168 | } |
| 169 | |
| 170 | /// `view`'s snapshot as the repository has it now. |
| 171 | fn current_snapshot(repo: &Repository, view: &str) -> Result<ViewSnapshot, Status> { |
no test coverage detected