Skip to content

Commit

Permalink
Run cargo fmt and cargo clippy (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeetfield authored Jul 18, 2023
1 parent 36533cf commit 18f6618
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
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

0 comments on commit 18f6618

Please sign in to comment.