refactor: 整理重构下载任务调度部分的代码,增强可读性和鲁棒性 (#531)
This commit is contained in:
@@ -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;
|
||||
|
||||
13
crates/bili_sync/src/utils/notify.rs
Normal file
13
crates/bili_sync/src/utils/notify.rs
Normal 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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user