MCPcopy Index your code
hub / github.com/encounter/objdiff / update_status

Function update_status

objdiff-core/src/jobs/mod.rs:202–222  ·  view source on GitHub ↗
(
    context: &JobContext,
    str: String,
    count: u32,
    total: u32,
    cancel: &Receiver<()>,
)

Source from the content-addressed store, hash-verified

200}
201
202fn update_status(
203 context: &JobContext,
204 str: String,
205 count: u32,
206 total: u32,
207 cancel: &Receiver<()>,
208) -> Result<()> {
209 let mut w =
210 context.status.write().map_err(|_| anyhow::Error::msg("Failed to lock job status"))?;
211 w.progress_items = Some([count, total]);
212 w.progress_percent = count as f32 / total as f32;
213 if should_cancel(cancel) {
214 w.status = "Cancelled".to_string();
215 return Err(anyhow::Error::msg("Cancelled"));
216 } else {
217 w.status = str;
218 }
219 drop(w);
220 context.waker.wake_by_ref();
221 Ok(())
222}
223
224fn should_cancel(rx: &Receiver<()>) -> bool {
225 match rx.try_recv() {

Callers 4

run_create_scratchFunction · 0.85
run_check_updateFunction · 0.85
run_updateFunction · 0.85
run_buildFunction · 0.85

Calls 3

should_cancelFunction · 0.85
writeMethod · 0.45
wake_by_refMethod · 0.45

Tested by

no test coverage detected