MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / check_view

Function check_view

libatomic/src/daemon/services_sandbox.rs:146–168  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

144/// still the view the grant was issued for (deleting a view and recreating
145/// its name does not revive a grant).
146fn 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.
171fn current_snapshot(repo: &Repository, view: &str) -> Result<ViewSnapshot, Status> {

Callers 7

open_sandboxMethod · 0.85
materializeMethod · 0.85
get_file_statesMethod · 0.85
get_changesMethod · 0.85
publish_provenanceMethod · 0.85
submit_changeMethod · 0.85
submit_attestationMethod · 0.85

Calls 4

domain_statusFunction · 0.85
read_txnMethod · 0.80
pristineMethod · 0.80
get_viewMethod · 0.45

Tested by

no test coverage detected