From acfc2e1d119eb9185670f588e2fe7c3f9c84954f Mon Sep 17 00:00:00 2001 From: Louis <836250617@qq.com> Date: Mon, 18 Mar 2024 05:44:14 +0800 Subject: [PATCH] improvement: quit while running `daemon` in a dir which is not initialized --- CHANGELOG.md | 5 +++++ Cargo.lock | 4 ++-- Cargo.toml | 2 +- fav_cli/src/bili/action.rs | 5 +++-- fav_cli/src/bili/mod.rs | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa261b..66f31c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [Unreleased] +## [0.2.11] - 2024-03-18 + +- bump dependencies. +- improvement: quit while running `daemon` in a dir which is not initialized. + ## [0.2.10] - 2024-03-13 - bump dependencies diff --git a/Cargo.lock b/Cargo.lock index 1e37672..a449c96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,7 +353,7 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fav" -version = "0.2.10" +version = "0.2.11" dependencies = [ "fav_cli", "tokio", @@ -363,7 +363,7 @@ dependencies = [ [[package]] name = "fav_cli" -version = "0.2.10" +version = "0.2.11" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 205f561..7072d8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ resolver = "2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace.package] -version = "0.2.10" +version = "0.2.11" authors = ["Louis <836250617@qq.com>"] description = "Back up your favorite online resources with CLI." license = "MIT" diff --git a/fav_cli/src/bili/action.rs b/fav_cli/src/bili/action.rs index e0efe69..b309fc2 100644 --- a/fav_cli/src/bili/action.rs +++ b/fav_cli/src/bili/action.rs @@ -136,11 +136,11 @@ pub(super) async fn pull(id: String) -> FavCoreResult<()> { sets.write() } -pub(super) async fn daemon(interval: u64) { +pub(super) async fn daemon(interval: u64) -> FavCoreResult<()> { if interval < 15 { warn!("Interval would better to be greater than 15 minutes."); } - pull_all().await.ok(); + pull_all().await?; loop { let next_ts_local = (chrono::Utc::now() + chrono::Duration::try_minutes(interval as i64).expect("invalid interval.")) @@ -161,6 +161,7 @@ pub(super) async fn daemon(interval: u64) { } } } + Ok(()) } fn try_find_set<'a>(sets: &'a mut BiliSets, id: &Id) -> Option<&'a mut BiliSet> { diff --git a/fav_cli/src/bili/mod.rs b/fav_cli/src/bili/mod.rs index b6099bd..519233f 100644 --- a/fav_cli/src/bili/mod.rs +++ b/fav_cli/src/bili/mod.rs @@ -141,7 +141,7 @@ impl Cli { } None => pull_all().await?, }, - Commands::Daemon { interval } => daemon(interval).await, + Commands::Daemon { interval } => daemon(interval).await?, Commands::Completion { shell } => { let mut cmd = Cli::command(); clap_complete::generate(shell, &mut cmd, "fav", &mut std::io::stdout());