make usb handle same as discord (#969)

This commit is contained in:
Logan McNaughton
2026-05-28 12:04:44 +02:00
committed by GitHub
parent e0efa80f44
commit e23894c2e6
2 changed files with 10 additions and 8 deletions
+2 -3
View File
@@ -243,9 +243,8 @@ pub async fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
}
}
}
if let Some(shutdown_tx) = &shutdown_tx {
ui::usb::close(shutdown_tx, usb_handle).await;
}
ui::usb::close(shutdown_tx, usb_handle).await;
} else if arg_count > 1 {
let mut config = ui::config::Config::new();
+8 -5
View File
@@ -175,16 +175,19 @@ pub fn init() -> (
}
pub async fn close(
shutdown_tx: &tokio::sync::watch::Sender<()>,
shutdown_tx: Option<tokio::sync::watch::Sender<()>>,
usb_handle: Option<tokio::task::JoinHandle<()>>,
) {
let _ = shutdown_tx.send(());
if let Some(mut handle) = usb_handle
&& tokio::time::timeout(std::time::Duration::from_secs(1), &mut handle)
&& let Some(shutdown_tx) = shutdown_tx
{
let _ = shutdown_tx.send(());
if tokio::time::timeout(std::time::Duration::from_secs(1), &mut handle)
.await
.is_err()
{
handle.abort();
{
handle.abort();
}
}
}