Add span to spawned prune task

This commit is contained in:
asonix 2023-12-12 17:43:10 -06:00
parent 91688d1b95
commit 4223d8a36f
1 changed files with 23 additions and 16 deletions

View File

@ -7,6 +7,7 @@ use crate::{
}; };
use futures_util::TryStreamExt; use futures_util::TryStreamExt;
use reqwest_middleware::ClientWithMiddleware; use reqwest_middleware::ClientWithMiddleware;
use tracing::Instrument;
pub(super) fn perform<'a, R, S>( pub(super) fn perform<'a, R, S>(
repo: &'a R, repo: &'a R,
@ -198,28 +199,34 @@ where
let repo = repo.clone(); let repo = repo.clone();
let store = store.clone(); let store = store.clone();
let res = actix_rt::spawn(async move { let current_span = tracing::Span::current();
let mut count = count; let span = tracing::debug_span!(parent: current_span, "ensure details");
if let Some(ident) = repo.identifier(hash.clone()).await? { let res = actix_rt::spawn(
match store.len(&ident).await { async move {
Err(e) if e.is_not_found() => { let mut count = count;
super::cleanup_hash(&repo, hash).await?;
count += 1; if let Some(ident) = repo.identifier(hash.clone()).await? {
match store.len(&ident).await {
Err(e) if e.is_not_found() => {
super::cleanup_hash(&repo, hash).await?;
repo.set( count += 1;
"prune-missing-queued",
Vec::from(count.to_be_bytes()).into(), repo.set(
) "prune-missing-queued",
.await?; Vec::from(count.to_be_bytes()).into(),
)
.await?;
}
_ => (),
} }
_ => (),
} }
}
Ok(count) as Result<u64, Error> Ok(count) as Result<u64, Error>
}) }
.instrument(span),
)
.await; .await;
match res { match res {