fix: simplify conditional checks and improve async handler usage across multiple files (#5156)

* fix: simplify conditional checks and improve async handler usage across multiple files

* fix: add missing AsyncHandler import in find_processes_by_name function

* fix: remove redundant AsyncHandler import in find_processes_by_name function
This commit is contained in:
Tunglies
2025-10-21 22:39:32 +08:00
committed by GitHub
parent 9c9aefe4cd
commit afb049ca17
8 changed files with 28 additions and 26 deletions

View File

@@ -50,10 +50,10 @@ impl CoreManager {
let now = Instant::now();
let mut last = self.last_update.lock();
if let Some(last_time) = *last {
if now.duration_since(last_time) < timing::CONFIG_UPDATE_DEBOUNCE {
return Ok(false);
}
if let Some(last_time) = *last
&& now.duration_since(last_time) < timing::CONFIG_UPDATE_DEBOUNCE
{
return Ok(false);
}
*last = Some(now);

View File

@@ -65,6 +65,7 @@ impl CoreManager {
}
async fn prepare_startup(&self) -> Result<()> {
#[cfg(target_os = "windows")]
self.wait_for_service_if_needed().await;
let mode = match SERVICE_MANAGER.lock().await.current() {
@@ -121,7 +122,4 @@ impl CoreManager {
let _ = backoff::future::retry(backoff, operation).await;
}
#[cfg(not(target_os = "windows"))]
async fn wait_for_service_if_needed(&self) {}
}

View File

@@ -1,11 +1,14 @@
use super::CoreManager;
#[cfg(windows)]
use crate::process::AsyncHandler;
use crate::{
AsyncHandler,
constants::{process, timing},
logging,
utils::logging::Type,
};
use anyhow::{Result, anyhow};
use anyhow::Result;
#[cfg(windows)]
use anyhow::anyhow;
impl CoreManager {
pub async fn cleanup_orphaned_processes(&self) -> Result<()> {