From 42cb5d8f19dc87f7a722dd7724e90d65f8845a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Thu, 17 Oct 2024 18:14:00 +0200 Subject: [PATCH] Apply suggestions from code review --- aw-sync/src/main.rs | 1 - aw-sync/src/sync_wrapper.rs | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/aw-sync/src/main.rs b/aw-sync/src/main.rs index fb7e3b67..243bff07 100644 --- a/aw-sync/src/main.rs +++ b/aw-sync/src/main.rs @@ -143,7 +143,6 @@ fn main() -> Result<(), Box> { // Start daemon Commands::Daemon {} => { info!("Starting daemon..."); - // TODO: log any errors before re-throwing daemon(&client)?; } // Perform basic sync diff --git a/aw-sync/src/sync_wrapper.rs b/aw-sync/src/sync_wrapper.rs index e0443c37..a2f5f181 100644 --- a/aw-sync/src/sync_wrapper.rs +++ b/aw-sync/src/sync_wrapper.rs @@ -17,21 +17,21 @@ pub fn pull_all(client: &AwClient) -> Result<(), Box> { fn wait_for_server(socket_addr: &std::net::SocketAddr) -> Result<(), Box> { // Check if server is running with exponential backoff let mut retry_delay = Duration::from_millis(100); - let max_retry_delay = Duration::from_secs(10); + let max_wait = Duration::from_secs(10); let mut total_wait = Duration::from_secs(0); - while total_wait < max_retry_delay { + while total_wait < max_wait { match TcpStream::connect_timeout(socket_addr, retry_delay) { Ok(_) => break, Err(_) => { std::thread::sleep(retry_delay); total_wait += retry_delay; - retry_delay = std::cmp::min(retry_delay * 2, max_retry_delay); + retry_delay *= 2; } } } - if total_wait >= max_retry_delay { + if total_wait >= max_wait { return Err(format!( "Local server {} not running after 10 seconds of retrying", socket_addr