Skip to content

Commit

Permalink
improvement: quit while running daemon in a dir which is not initia…
Browse files Browse the repository at this point in the history
…lized
  • Loading branch information
kingwingfly committed Mar 17, 2024
1 parent 11245b0 commit acfc2e1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
description = "Back up your favorite online resources with CLI."
license = "MIT"
Expand Down
5 changes: 3 additions & 2 deletions fav_cli/src/bili/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
Expand All @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion fav_cli/src/bili/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit acfc2e1

Please sign in to comment.