fix: only write IP cache after API call
previously, when the API call would fail (for whatever reason), the cached IP had already been written, so following executions wouldn't attempt to update the IP, even though the previous attempt had failed.
This commit is contained in:
parent
ec8b893f6a
commit
37bd9b1f24
1 changed files with 9 additions and 9 deletions
18
src/main.rs
18
src/main.rs
|
@ -62,15 +62,6 @@ fn main() -> Result<()> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
if should_use_cache {
|
||||
println!(
|
||||
"Saving current IP {} to cache file {:?}...",
|
||||
¤t_ip,
|
||||
&args.cache.clone().unwrap()
|
||||
);
|
||||
write_file(&args.cache.unwrap(), ¤t_ip)?;
|
||||
}
|
||||
|
||||
let (api_token, zone, domain) = match args.config {
|
||||
Some(c) => {
|
||||
let config_str = read_file(&c)?;
|
||||
|
@ -91,6 +82,15 @@ fn main() -> Result<()> {
|
|||
&domain, ¤t_ip
|
||||
);
|
||||
|
||||
if should_use_cache {
|
||||
println!(
|
||||
"Saving current IP {} to cache file {:?}...",
|
||||
¤t_ip,
|
||||
&args.cache.clone().unwrap()
|
||||
);
|
||||
write_file(&args.cache.unwrap(), ¤t_ip)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue