From 2a145822fd2619eff7df891ba98fb9a470a1e888 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Wed, 13 Dec 2023 20:12:47 -0500 Subject: [PATCH] Wait until qbittorrent is reachable on startup --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index bbe9e2d..c248287 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,13 @@ fn main() -> anyhow::Result<()> { println!("Couldn't find {}", config.port_file); println!("Trying again in 10 seconds"); std::thread::sleep(Duration::from_secs(10)); - } + } + + while reqwest::blocking::get(config.qbit_full_url()).and_then(|r| r.error_for_status()).is_err() { + println!("Couldn't reach qbittorrent at {}", config.qbit_full_url()); + println!("Trying again in 10 seconds"); + std::thread::sleep(Duration::from_secs(10)); + } let config_clone = config.clone(); let mut watcher = notify::recommended_watcher(move |res: Result| {