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

Method submit

atomic-cli/src/remote_sandbox.rs:207–262  ·  view source on GitHub ↗
(
        &self,
        root: &Path,
        base_state: String,
        hash: Hash,
        bytes: Vec<u8>,
    )

Source from the content-addressed store, hash-verified

205 }
206
207 fn submit(
208 &self,
209 root: &Path,
210 base_state: String,
211 hash: Hash,
212 bytes: Vec<u8>,
213 ) -> Result<SubmittedOutcome, String> {
214 exchange(root, move |repository, target, channel| async move {
215 let fence = Hash::from_base32(base_state.as_bytes()).ok_or("bad base state")?;
216 let response = sandbox_client(channel)
217 .submit_change(pb::SubmitChangeRequest {
218 repository: Some(repository),
219 meta: Some(pb::RequestMeta {
220 request_id: uuid::Uuid::new_v4().to_string(),
221 observed_at: None,
222 }),
223 change: Some(wire::change_bundle(&hash, bytes)),
224 expected_snapshot: Some(wire::view_snapshot("", &fence, None)),
225 target: Some(target),
226 })
227 .await
228 .map_err(refused)?
229 .into_inner();
230 match response.outcome.ok_or("no outcome in SubmitChange")? {
231 pb::submit_change_response::Outcome::Submitted(submitted) => {
232 let skeleton = wire::skeleton_from_proto(
233 &submitted.skeleton.ok_or("no skeleton in SubmitChange")?,
234 )?;
235 let effective = response
236 .meta
237 .and_then(|m| m.snapshot)
238 .map(|s| wire::snapshot_fence(&s))
239 .transpose()?
240 .unwrap_or_default();
241 Ok(Ok((
242 Submitted {
243 hash,
244 state: skeleton.view.state.to_base32(),
245 effective,
246 },
247 skeleton,
248 )))
249 }
250 pb::submit_change_response::Outcome::Refused(refused) => {
251 let info = refused.rejection.ok_or("no rejection in a refusal")?;
252 let rejection = wire::rejection_from_error_info(&info)
253 .ok_or_else(|| info.message.clone())?;
254 let skeleton = refused
255 .skeleton
256 .map(|s| wire::skeleton_from_proto(&s))
257 .transpose()?;
258 Ok(Err((rejection, skeleton)))
259 }
260 }
261 })
262 }
263
264 fn changes(&self, root: &Path, hashes: Vec<Hash>) -> Result<Vec<ChangeFile>, String> {

Callers 2

measureFunction · 0.45
submit_recordedMethod · 0.45

Calls 12

exchangeFunction · 0.85
sandbox_clientFunction · 0.85
change_bundleFunction · 0.85
view_snapshotFunction · 0.85
skeleton_from_protoFunction · 0.85
snapshot_fenceFunction · 0.85
submit_changeMethod · 0.80
as_bytesMethod · 0.45
into_innerMethod · 0.45
to_base32Method · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected