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

Method get_changes

libatomic/src/daemon/services_sandbox.rs:590–654  ·  view source on GitHub ↗
(
        &self,
        request: Request<GetChangesRequest>,
    )

Source from the content-addressed store, hash-verified

588 }
589
590 async fn get_changes(
591 &self,
592 request: Request<GetChangesRequest>,
593 ) -> Result<Response<GetChangesResponse>, Status> {
594 /// GetCapabilities' `max_changes_per_request`.
595 const MAX_CHANGES: usize = 64;
596 let caller = self.state.sandbox_caller(&request)?;
597 let request = request.into_inner();
598 let repository = repository_ref(&request.repository)?;
599 let handle = self.state.resolve(&repository)?;
600 self.state.log_rpc("GetChanges", Some(&handle));
601 let view = data_view(
602 caller.as_ref(),
603 &handle,
604 &repository,
605 request.target.as_ref(),
606 "sandbox.read",
607 )?;
608 if request.hashes.len() > MAX_CHANGES {
609 return Err(domain_status(
610 ErrorCode::ResourceExhausted,
611 format!("at most {MAX_CHANGES} changes per request"),
612 ));
613 }
614 let hashes = request
615 .hashes
616 .iter()
617 .map(|h| wire::hash_from_proto(Some(h)))
618 .collect::<Result<Vec<_>, _>>()
619 .map_err(invalid)?;
620 let expected = request.expected_snapshot;
621 let gate_handle = handle.clone();
622 let _gate = gate_handle.exclusive().await;
623 if let Some(caller) = &caller {
624 caller.revalidate(&self.state)?;
625 }
626 let outcome = tokio::task::spawn_blocking(move || {
627 let repo = handle.repository_readonly()?;
628 check_view(&repo, caller.as_ref(), &view)?;
629 if let Some(expected) = &expected {
630 fence(&repo, &view, expected)?;
631 }
632 Ok::<_, Status>(
633 match repo
634 .export_sandbox_changes(&view, &hashes)
635 .map_err(view_error)?
636 {
637 Ok(changes) => get_changes_response::Outcome::Changes(ChangesPayload {
638 changes: changes
639 .into_iter()
640 .map(|(hash, bytes)| wire::change_bundle(&hash, bytes))
641 .collect(),
642 }),
643 Err(rejection) => get_changes_response::Outcome::Refused(
644 wire::rejection_error_info(&rejection),
645 ),
646 },
647 )

Callers 2

changesMethod · 0.80
changesMethod · 0.80

Calls 15

repository_refFunction · 0.85
data_viewFunction · 0.85
domain_statusFunction · 0.85
hash_from_protoFunction · 0.85
check_viewFunction · 0.85
fenceFunction · 0.85
change_bundleFunction · 0.85
rejection_error_infoFunction · 0.85
sandbox_callerMethod · 0.80
log_rpcMethod · 0.80
as_refMethod · 0.80
exclusiveMethod · 0.80

Tested by 1

changesMethod · 0.64