From 6d259a0eeab628d68d43abff467d1e9e5fdd7606 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 23 Dec 2023 13:29:30 -0600 Subject: [PATCH] Don't kill already-exited processes, don't log tmp_dir when fetching details --- src/lib.rs | 2 +- src/process.rs | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bfbf4a7..fdada78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1121,7 +1121,7 @@ async fn details_query( } /// Fetch file details -#[tracing::instrument(name = "Fetching details", skip(repo, store, config))] +#[tracing::instrument(name = "Fetching details", skip(tmp_dir, repo, store, config))] async fn details( alias: web::Path>, tmp_dir: web::Data, diff --git a/src/process.rs b/src/process.rs index 04dfc96..8dd0ceb 100644 --- a/src/process.rs +++ b/src/process.rs @@ -223,8 +223,7 @@ impl Process { Ok(Ok(status)) => Err(ProcessError::Status(command, status)), Ok(Err(e)) => Err(ProcessError::Other(e)), Err(_) => { - child.kill().await.map_err(ProcessError::Other)?; - + let _ = child.kill().await; Err(ProcessError::Timeout(command)) } } @@ -268,19 +267,18 @@ impl Process { child.wait().await }; - let error = match child_fut.with_timeout(timeout).await { + match child_fut.with_timeout(timeout).await { Ok(Ok(status)) if status.success() => { guard.disarm(); - return Ok(()); + Ok(()) } - Ok(Ok(status)) => ProcessError::Status(command2, status), - Ok(Err(e)) => ProcessError::Other(e), - Err(_) => ProcessError::Timeout(command2), - }; - - child.kill().await.map_err(ProcessError::Other)?; - - Err(error) + Ok(Ok(status)) => Err(ProcessError::Status(command2, status)), + Ok(Err(e)) => Err(ProcessError::Other(e)), + Err(_) => { + child.kill().await.map_err(ProcessError::Other)?; + Err(ProcessError::Timeout(command2)) + } + } }); ProcessRead {