diff options
author | initard <solo@softwareag.com> | 2022-06-11 18:44:45 +0100 |
---|---|---|
committer | initard <solo@softwareag.com> | 2022-06-16 15:18:10 +0100 |
commit | ff9b60b37fa10970ea7228763f08d5176b64f354 (patch) | |
tree | 7f3529eb382f976d7cb68e6b99bfe0d1e94d8fbd /crates | |
parent | 881eddd332567b8cc61f1417e93569743ad93999 (diff) |
tedge_agent fixing clippy warnings #825
Signed-off-by: initard <solo@softwareag.com>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/core/tedge_agent/src/agent.rs | 2 | ||||
-rw-r--r-- | crates/core/tedge_agent/src/restart_operation_handler.rs | 20 |
2 files changed, 8 insertions, 14 deletions
diff --git a/crates/core/tedge_agent/src/agent.rs b/crates/core/tedge_agent/src/agent.rs index 8fe3e18a..243463f1 100644 --- a/crates/core/tedge_agent/src/agent.rs +++ b/crates/core/tedge_agent/src/agent.rs @@ -144,7 +144,7 @@ impl SmAgentConfig { let tedge_download_dir = tedge_config.query_string(TmpPathSetting)?.into(); - let tedge_log_dir: String = tedge_config.query_string(LogPathSetting)?.into(); + let tedge_log_dir: String = tedge_config.query_string(LogPathSetting)?; let tedge_log_dir = PathBuf::from(&format!("{tedge_log_dir}/{AGENT_LOG_PATH}")); let tedge_run_dir = tedge_config.query_string(RunPathSetting)?.into(); diff --git a/crates/core/tedge_agent/src/restart_operation_handler.rs b/crates/core/tedge_agent/src/restart_operation_handler.rs index ed1b46ab..29342cb0 100644 --- a/crates/core/tedge_agent/src/restart_operation_handler.rs +++ b/crates/core/tedge_agent/src/restart_operation_handler.rs @@ -1,13 +1,7 @@ pub mod restart_operation { use crate::error::AgentError; - use std::{ - fs::File, - fs::OpenOptions, - io::Read, - io::Write, - path::{Path, PathBuf}, - }; + use std::{fs::File, fs::OpenOptions, io::Read, io::Write, path::Path}; use time::OffsetDateTime; const SLASH_RUN_PATH_TEDGE_AGENT_RESTART: &str = "tedge_agent/tedge_agent_restart"; @@ -20,7 +14,7 @@ pub mod restart_operation { /// ``` /// let () = RestartOperationHelper::create_slash_run_file()?; /// ``` - pub fn create_slash_run_file(run_dir: &PathBuf) -> Result<(), AgentError> { + pub fn create_slash_run_file(run_dir: &Path) -> Result<(), AgentError> { let path = &run_dir.join(SLASH_RUN_PATH_TEDGE_AGENT_RESTART); let path = Path::new(path); @@ -40,13 +34,13 @@ pub mod restart_operation { Ok(()) } - pub fn slash_run_file_exists(run_dir: &PathBuf) -> bool { + pub fn slash_run_file_exists(run_dir: &Path) -> bool { let path = &run_dir.join(SLASH_RUN_PATH_TEDGE_AGENT_RESTART); std::path::Path::new(path).exists() } /// returns the datetime of `SLASH_RUN_PATH_TEDGE_AGENT_RESTART` "modified at". - fn get_restart_file_datetime(run_dir: &PathBuf) -> Result<time::OffsetDateTime, AgentError> { + fn get_restart_file_datetime(run_dir: &Path) -> Result<time::OffsetDateTime, AgentError> { let mut file = File::open(&run_dir.join(SLASH_RUN_PATH_TEDGE_AGENT_RESTART))?; let mut contents = String::new(); file.read_to_string(&mut contents)?; @@ -100,15 +94,15 @@ pub mod restart_operation { } /// checks if system rebooted by comparing dt of tedge_agent_restart with dt of system restart. - pub fn has_rebooted(run_dir: &PathBuf) -> Result<bool, AgentError> { + pub fn has_rebooted(run_dir: &Path) -> Result<bool, AgentError> { // there is no slash run file after the reboot, so we assume success. // this is true for most of the cases as "/run/" is normally cleared after a reboot. - if !slash_run_file_exists(&run_dir) { + if !slash_run_file_exists(run_dir) { return Ok(true); } let system_reboot_dt = get_system_uptime()?; - let tedge_restart_file_dt = get_restart_file_datetime(&run_dir)?; + let tedge_restart_file_dt = get_restart_file_datetime(run_dir)?; Ok(system_reboot_dt > tedge_restart_file_dt) } |