Fix clippy warmings
This commit is contained in:
parent
1ea0ea2ed1
commit
171d051710
|
@ -1,6 +1,5 @@
|
|||
use log::info;
|
||||
use peach_lib::dyndns_client::dyndns_update_ip;
|
||||
use log::{info};
|
||||
|
||||
|
||||
fn main() {
|
||||
// initalize the logger
|
||||
|
@ -9,4 +8,4 @@ fn main() {
|
|||
info!("Running peach-dyndns-updater");
|
||||
let result = dyndns_update_ip();
|
||||
info!("result: {:?}", result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,11 +72,8 @@ fn save_peach_config(peach_config: PeachConfig) -> Result<PeachConfig, PeachErro
|
|||
pub fn load_peach_config() -> Result<PeachConfig, PeachError> {
|
||||
let peach_config_exists = std::path::Path::new(YAML_PATH).exists();
|
||||
|
||||
let peach_config: PeachConfig;
|
||||
|
||||
// if this is the first time loading peach_config, we can create a default here
|
||||
if !peach_config_exists {
|
||||
peach_config = PeachConfig {
|
||||
let peach_config: PeachConfig = if !peach_config_exists {
|
||||
PeachConfig {
|
||||
external_domain: "".to_string(),
|
||||
dyn_domain: "".to_string(),
|
||||
dyn_dns_server_address: DEFAULT_DYN_SERVER_ADDRESS.to_string(),
|
||||
|
@ -87,7 +84,7 @@ pub fn load_peach_config() -> Result<PeachConfig, PeachError> {
|
|||
ssb_admin_ids: Vec::new(),
|
||||
admin_password_hash: "".to_string(),
|
||||
temporary_password_hash: "".to_string(),
|
||||
};
|
||||
}
|
||||
}
|
||||
// otherwise we load peach config from disk
|
||||
else {
|
||||
|
@ -95,8 +92,8 @@ pub fn load_peach_config() -> Result<PeachConfig, PeachError> {
|
|||
source,
|
||||
path: YAML_PATH.to_string(),
|
||||
})?;
|
||||
peach_config = serde_yaml::from_str(&contents)?;
|
||||
}
|
||||
serde_yaml::from_str(&contents)?
|
||||
};
|
||||
|
||||
Ok(peach_config)
|
||||
}
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
use std::{
|
||||
fs,
|
||||
fs::OpenOptions,
|
||||
fs::File,
|
||||
io::Write,
|
||||
process::{Command, Stdio},
|
||||
process::{Command},
|
||||
str::FromStr,
|
||||
};
|
||||
use std::ffi::OsStr;
|
||||
|
@ -212,7 +211,7 @@ pub fn get_num_seconds_since_successful_dns_update() -> Result<Option<i64>, Peac
|
|||
})?;
|
||||
// replace newline if found
|
||||
// TODO: maybe we can use `.trim()` instead
|
||||
let contents = contents.replace("\n", "");
|
||||
let contents = contents.replace('\n', "");
|
||||
// TODO: consider adding additional context?
|
||||
let time_ran_dt = DateTime::parse_from_rfc3339(&contents).map_err(|source| {
|
||||
PeachError::ParseDateTime {
|
||||
|
@ -235,16 +234,15 @@ pub fn is_dns_updater_online() -> Result<bool, PeachError> {
|
|||
let is_enabled = peach_config.dyn_enabled;
|
||||
// then check if it has successfully run within the last 6 minutes (60*6 seconds)
|
||||
let num_seconds_since_successful_update = get_num_seconds_since_successful_dns_update()?;
|
||||
let ran_recently: bool;
|
||||
match num_seconds_since_successful_update {
|
||||
let ran_recently: bool = match num_seconds_since_successful_update {
|
||||
Some(seconds) => {
|
||||
ran_recently = seconds < (60 * 6);
|
||||
seconds < (60 * 6)
|
||||
}
|
||||
// if the value is None, then the last time it ran successfully is unknown
|
||||
None => {
|
||||
ran_recently = false;
|
||||
false
|
||||
}
|
||||
}
|
||||
};
|
||||
// debug log
|
||||
info!("is_dyndns_enabled: {:?}", is_enabled);
|
||||
info!("dyndns_ran_recently: {:?}", ran_recently);
|
||||
|
|
Loading…
Reference in New Issue