Skip to content

Commit

Permalink
Lint cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
aamohd committed Dec 20, 2024
1 parent 6c9825c commit 31d6c35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
8 changes: 4 additions & 4 deletions hipcheck/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
},
};
use kdl::{KdlDocument, KdlNode, KdlValue};
use std::{path::Path, str::FromStr, env};
use std::{env, path::Path, str::FromStr};

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PluginBackoffInterval {
Expand Down Expand Up @@ -281,18 +281,18 @@ impl ExecConfig {

pub fn find_file() -> Result<Self, Error> {
let exec_file = "Exec.kdl";
let mut curr_dir= env::current_dir().unwrap();
let mut curr_dir = env::current_dir().unwrap();
loop {
let target_path = curr_dir.join(exec_file);
let target_ref = target_path.as_path();
if target_ref.exists() {
// Parse found file
log::info!("Using Exec Config at {:?}", target_ref);
return Self::from_file(target_ref)
return Self::from_file(target_ref);
}
if let Some(parent) = curr_dir.parent() {
curr_dir = parent.to_path_buf();
} else {
} else {
// If file not found, use default values
log::info!("Using a default Exec Config");
return Self::default();
Expand Down
14 changes: 6 additions & 8 deletions hipcheck/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,23 +307,21 @@ fn load_exec_config(exec_path: Option<&Path>) -> Result<ExecConfig> {
phase.enable_steady_tick(Duration::from_millis(100));

// Resolve the path to the exec config file.
let exec_config: ExecConfig;

match exec_path {
let exec_config = match exec_path {
Some(p) => {
// Use the path provided
if !p.exists() {
hc_error!("Failed to load exec config. Please make sure the path set by the --exec flag exists.");
}
exec_config = ExecConfig::from_file(p)
ExecConfig::from_file(p)
.context("Failed to load the exec config. Please make sure the exec config file is in the provided location and is formatted correctly.")
.unwrap();
},
.unwrap()
}
None => {
// Search for file if not provided
exec_config = ExecConfig::find_file()
ExecConfig::find_file()
.context("Failed to load the exec config. Please make sure the exec config file is in the provided location and is formatted correctly.")
.unwrap();
.unwrap()
}
};

Expand Down

0 comments on commit 31d6c35

Please sign in to comment.