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

Function diff_working_copy_impl

libatomic/src/daemon/services_query.rs:23–60  ·  view source on GitHub ↗

The handler body, shared with the trait impl in `services.rs`.

(
    state: &Arc<DaemonState>,
    request: Request<DiffWorkingCopyRequest>,
)

Source from the content-addressed store, hash-verified

21
22/// The handler body, shared with the trait impl in `services.rs`.
23pub async fn diff_working_copy_impl(
24 state: &Arc<DaemonState>,
25 request: Request<DiffWorkingCopyRequest>,
26) -> Result<Response<<super::services::QueryImpl as repository_query_service_server::RepositoryQueryService>::DiffWorkingCopyStream>, Status>{
27 let request = request.into_inner();
28 let handle = state.resolve(request.repository.as_ref().unwrap())?;
29 state.log_rpc("DiffWorkingCopy", Some(&handle));
30 let scope = request.working_copy.unwrap_or_default();
31 let stat_only = request.stat_only;
32 let paths = scope.paths;
33
34 let (sender, receiver) = tokio::sync::mpsc::channel::<Result<DiffChunk, Status>>(16);
35 let handle_for_task = handle;
36 tokio::spawn(async move {
37 let gate_handle = handle_for_task.clone();
38 let _gate = gate_handle.exclusive().await;
39 let result = tokio::task::spawn_blocking(move || {
40 compute_working_copy_diff(&handle_for_task, &paths, scope.include_untracked, stat_only)
41 })
42 .await
43 .unwrap_or_else(|error| Err(Status::internal(error.to_string())));
44 match result {
45 Ok(chunks) => {
46 for chunk in chunks {
47 if sender.send(Ok(chunk)).await.is_err() {
48 break; // client went away
49 }
50 }
51 }
52 Err(error) => {
53 let _ = sender.send(Err(error)).await;
54 }
55 }
56 });
57 Ok(Response::new(Box::pin(
58 tokio_stream::wrappers::ReceiverStream::new(receiver),
59 )))
60}
61
62/// Compute the working-copy diff chunks: recorded graph content (via
63/// `get_file_content_on_view`) against the on-disk bytes, unified-diffed

Callers 1

diff_working_copyMethod · 0.85

Calls 8

as_refMethod · 0.80
log_rpcMethod · 0.80
exclusiveMethod · 0.80
into_innerMethod · 0.45
resolveMethod · 0.45
unwrapMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected