From 178f8182840435b419600e91e9212756f450ff2e Mon Sep 17 00:00:00 2001 From: edouardparis Date: Tue, 4 Feb 2025 10:39:17 +0100 Subject: [PATCH] fix subscriptions: channel size and ContentLength error --- liana-gui/src/download.rs | 16 ++++++++-------- liana-gui/src/loader.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/liana-gui/src/download.rs b/liana-gui/src/download.rs index 6423d6f1..e573dfd2 100644 --- a/liana-gui/src/download.rs +++ b/liana-gui/src/download.rs @@ -22,9 +22,7 @@ pub fn file( fn download(url: String) -> impl Stream> { try_channel(100, move |mut output| async move { let response = reqwest::get(&url).await?; - let total = response - .content_length() - .ok_or(DownloadError::NoContentLength)?; + let total = response.content_length(); let _ = output.send(Progress::Downloading(0.0)).await; @@ -37,11 +35,13 @@ fn download(url: String) -> impl Stream> downloaded += chunk.len(); bytes.append(&mut chunk.to_vec()); - let _ = output - .send(Progress::Downloading( - 100.0 * downloaded as f32 / total as f32, - )) - .await; + if let Some(total) = total { + let _ = output + .send(Progress::Downloading( + 100.0 * downloaded as f32 / total as f32, + )) + .await; + } } let _ = output.send(Progress::Finished(bytes)).await; diff --git a/liana-gui/src/loader.rs b/liana-gui/src/loader.rs index 7fe9a0f5..4451da99 100644 --- a/liana-gui/src/loader.rs +++ b/liana-gui/src/loader.rs @@ -328,7 +328,7 @@ impl Loader { } fn get_bitcoind_log(log_path: PathBuf) -> impl Stream> { - channel(1, move |mut output| async move { + channel(5, move |mut output| async move { loop { // Reduce the io load. tokio::time::sleep(Duration::from_millis(500)).await;