refactor: 整理重构下载任务调度部分的代码,增强可读性和鲁棒性 (#531)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-11-11 01:29:52 +08:00
committed by GitHub
parent 8931cb5d2a
commit 670f21a725
6 changed files with 250 additions and 192 deletions

View File

@@ -4,6 +4,7 @@ pub mod filenamify;
pub mod format_arg;
pub mod model;
pub mod nfo;
pub mod notify;
pub mod rule;
pub mod signal;
pub mod status;

View File

@@ -0,0 +1,13 @@
use crate::bilibili::BiliClient;
use crate::config::Config;
use crate::notifier::NotifierAllExt;
pub fn error_and_notify(config: &Config, bili_client: &BiliClient, msg: String) {
error!("{msg}");
if let Some(notifiers) = &config.notifiers
&& !notifiers.is_empty()
{
let (notifiers, inner_client) = (notifiers.clone(), bili_client.inner_client().clone());
tokio::spawn(async move { notifiers.notify_all(&inner_client, msg.as_str()).await });
}
}