From c381c3666e8aa5d51e1e8a25012616a7b387dde6 Mon Sep 17 00:00:00 2001 From: 22earth Date: Sat, 15 Oct 2022 17:34:58 +0800 Subject: [PATCH] fixed: check concurrent --- README.md | 4 ++-- src/app.rs | 2 +- src/main.rs | 2 +- src/yiyiwu.rs | 11 ++++++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8d350d6..891dc81 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Rss2pan -将 Rss 订阅离线下载到网盘。目前支持 115 +将 Rss 订阅离线下载到 115 网盘。 ## 关于 @@ -30,7 +30,7 @@ ```bash # 查看帮助 rss2pan -h -# 直接运行。读取 rss.json,进行添加离线任务 +# 直接运行。读取 rss.json,依次添加离线任务 rss2pan # 并发请求 rss 网站。然后再添加 115 离线任务 rss2pan -m diff --git a/src/app.rs b/src/app.rs index 08fca8b..4f1941a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -29,7 +29,7 @@ pub fn build_app() -> Command<'static> { fn t_cmd() { let cmd = build_app(); let matches = cmd.clone().try_get_matches_from(["rss2pan", "-m"]).unwrap(); - assert!(matches.contains_id("concurrent")); + assert_eq!(matches.get_one::("concurrent").copied(), Some(true)); let matches = cmd.clone().try_get_matches_from(["rss2pan"]).unwrap(); assert_eq!(matches.get_one::("concurrent").copied(), Some(false)); } diff --git a/src/main.rs b/src/main.rs index 14944d5..88bcc83 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ async fn main() -> anyhow::Result<()> { } return Ok(()); } - if matches.contains_id("concurrent") { + if matches.get_one::("concurrent").copied() == Some(true) { if let Err(err) = execute_tasks(&service).await { println!("{}", err); } diff --git a/src/yiyiwu.rs b/src/yiyiwu.rs index 5a3588b..03b1f52 100644 --- a/src/yiyiwu.rs +++ b/src/yiyiwu.rs @@ -140,7 +140,16 @@ impl Yiyiwu { .filter(|item| !service.has_item(&item.magnet)) .map(|item| &*item.magnet) .collect(); - // log::debug!("tasks: {:?}", tasks); + // 测试用的开关 + if std::env::var("RSS2PAN_LOG").is_ok() { + log::info!( + "[RSS2PAN_LOG] [{}] [{}] has {} tasks", + config.name, + config.url, + tasks.len() + ); + continue; + } if tasks.len() == 0 { log::info!("[{}] has 0 task", config.name); continue;