Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cargo fmt and cargo clippy #65

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rozy/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct App {
}

pub fn find_app(config: &serde_yaml::Mapping, app: &String) -> Result<App> {
App::new(app, &config)
App::new(app, config)
.with_context(|| format!("While attempting to find the app {} to run", app))
}

Expand Down
4 changes: 3 additions & 1 deletion rozy/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use std::{collections::HashMap, time::SystemTime};
use serde_yaml::Mapping as Config;

pub fn config_mtime() -> Result<SystemTime> {
return Ok(std::fs::metadata(&get_ozy_dir()?.join("ozy.yaml"))?.modified().unwrap());
Ok(std::fs::metadata(&get_ozy_dir()?.join("ozy.yaml"))?
.modified()
.unwrap())
}

pub fn load_config(base_config_filename_override: Option<&str>) -> Result<Config> {
Expand Down
15 changes: 7 additions & 8 deletions rozy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ fn should_update(config: &serde_yaml::Mapping) -> Result<bool> {
match config.get("ozy_update_every") {
Some(serde_yaml::Value::Number(update_every)) => {
let update_every = Duration::from_secs(update_every.as_u64().unwrap_or_default());
let since_last_update = std::time::SystemTime::now().duration_since(config::config_mtime().context("While determining config mtime")?)?;
return Ok(!update_every.is_zero() && since_last_update >= update_every);
},
_ => return Ok(false),
let since_last_update = std::time::SystemTime::now().duration_since(
config::config_mtime().context("While determining config mtime")?,
)?;
Ok(!update_every.is_zero() && since_last_update >= update_every)
}
_ => Ok(false),
}
}

Expand Down Expand Up @@ -471,10 +473,7 @@ fn main() -> Result<(), Error> {
makefile_var,
app_names,
} => makefile_config(makefile_var, app_names, did_path_contain_ozy),
Commands::Run {
app_name,
app_args,
} => run(app_name, app_args),
Commands::Run { app_name, app_args } => run(app_name, app_args),
Commands::Update { url } => update(&exe_path, url),
Commands::Sync => sync(&exe_path),
}
Expand Down