about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-08-19 21:11:08 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-08-19 21:11:08 +0200
commit9fb8d44bf850dc398714d101f061e5f1c27647a0 (patch)
tree4e80750b391d3ad29728263b8b1b7bd3887ea254
parentfs-tracer: add file restoring ops (diff)
downloadfs-tracer-9fb8d44bf850dc398714d101f061e5f1c27647a0.tar.gz
fs-tracer-9fb8d44bf850dc398714d101f061e5f1c27647a0.tar.bz2
fs-tracer-9fb8d44bf850dc398714d101f061e5f1c27647a0.zip
fs-tracer: handle exit in restore file thread
-rw-r--r--fs-tracer/src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs-tracer/src/main.rs b/fs-tracer/src/main.rs
index ba52ff3..2616ac9 100644
--- a/fs-tracer/src/main.rs
+++ b/fs-tracer/src/main.rs
@@ -113,8 +113,14 @@ async fn main() -> Result<(), anyhow::Error> {
 
     //TODO: Create thread getting restored files every X secs and actually restore them
     let thread_api_key = fs_tracer_api_key.clone();
+    let thread_exit = exit.clone();
     tokio::spawn(async move {
         loop {
+            if thread_exit.load(Ordering::Relaxed) {
+                info!("STOPPED THREAD, RETURNING");
+                return;
+            }
+            println!("Getting files to restore");
             let resp = ureq::get(&format!("http://leunam.dev:9999/api/v1/restored-files/"))
                 .set("API_KEY", &thread_api_key)
                 .call()
@@ -143,7 +149,7 @@ async fn main() -> Result<(), anyhow::Error> {
                 }
             }
 
-            std::thread::sleep(Duration::from_secs(20));
+            std::thread::sleep(Duration::from_secs(2));
         }
     });