From 37bd9b1f249dd390a025341b502d486476a8549d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Christian=20Gr=C3=BCnhage?= Date: Mon, 20 Apr 2020 23:13:42 +0200 Subject: [PATCH] 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. --- src/main.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index b2f3d3c..9ad2f41 100644 --- a/src/main.rs +++ b/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(()) }