Skip to content

Commit

Permalink
refactor: use while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Devdutt Shenoi committed Apr 4, 2024
1 parent 4be8796 commit f936fae
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions uplink/src/collector/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,7 @@ impl FileDownloader {
self.reload().await;

info!("Downloader thread is ready to receive download actions");
loop {
let action = match self.actions_rx.recv_async().await {
Ok(a) => a,
Err(e) => {
error!("Downloader thread had to stop: {e}");
break;
}
};
while let Ok(action) = self.actions_rx.recv_async().await {
self.action_id = action.action_id.clone();
let mut state = match DownloadState::new(action, &self.config) {
Ok(s) => s,
Expand All @@ -178,6 +171,8 @@ impl FileDownloader {
let status = ActionResponse::done(&self.action_id, "Downloaded", Some(action));
self.bridge_tx.send_action_response(status).await;
}

error!("Downloader thread stopped");
}

// reloads a download if it wasn't completed during the previous run of uplink
Expand Down

0 comments on commit f936fae

Please sign in to comment.