diff --git a/sr_download/src/main.rs b/sr_download/src/main.rs index f89da6c..470f03e 100644 --- a/sr_download/src/main.rs +++ b/sr_download/src/main.rs @@ -114,8 +114,10 @@ async fn serve_mode(mut stop_receiver: Receiver<()>) -> anyhow::Result<()> { event!(Level::INFO, "{}", "结束下载!".yellow()); // 结束 db db_connect.close().await?; - if conf.serve.enable && web_waiter.is_some() { - web_waiter.unwrap().abort(); + if conf.serve.enable { + if let Some(web_waiter) = web_waiter { + web_waiter.abort(); + } } return Ok(()); } diff --git a/sr_download/src/serve.rs b/sr_download/src/serve.rs index e211749..33c0dda 100644 --- a/sr_download/src/serve.rs +++ b/sr_download/src/serve.rs @@ -2,7 +2,7 @@ use axum::{extract::State, routing::get, Json, Router}; use sea_orm::{ActiveEnum, DatabaseConnection}; use serde::{Deserialize, Serialize}; -use crate::{config::ConfigFile, db_part}; +use crate::db_part; use migration::SaveId; /// 最后一个数据的信息 @@ -79,7 +79,7 @@ async fn get_last_ship(State(db): State) -> Json anyhow::Result<()> { let conf = crate::config::ConfigFile::try_read()?; - + let listener = tokio::net::TcpListener::bind(conf.serve.host_with_port.clone()).await?; let db = db_part::connect_server(&conf).await?; let app = Router::new()