Skip to content

Commit 178f818

Browse files
committed
fix subscriptions: channel size and ContentLength error
1 parent 8c800a2 commit 178f818

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

liana-gui/src/download.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ pub fn file<I: 'static + Hash + Copy + Send + Sync, T: ToString>(
2222
fn download(url: String) -> impl Stream<Item = Result<Progress, DownloadError>> {
2323
try_channel(100, move |mut output| async move {
2424
let response = reqwest::get(&url).await?;
25-
let total = response
26-
.content_length()
27-
.ok_or(DownloadError::NoContentLength)?;
25+
let total = response.content_length();
2826

2927
let _ = output.send(Progress::Downloading(0.0)).await;
3028

@@ -37,11 +35,13 @@ fn download(url: String) -> impl Stream<Item = Result<Progress, DownloadError>>
3735
downloaded += chunk.len();
3836
bytes.append(&mut chunk.to_vec());
3937

40-
let _ = output
41-
.send(Progress::Downloading(
42-
100.0 * downloaded as f32 / total as f32,
43-
))
44-
.await;
38+
if let Some(total) = total {
39+
let _ = output
40+
.send(Progress::Downloading(
41+
100.0 * downloaded as f32 / total as f32,
42+
))
43+
.await;
44+
}
4545
}
4646

4747
let _ = output.send(Progress::Finished(bytes)).await;

liana-gui/src/loader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl Loader {
328328
}
329329

330330
fn get_bitcoind_log(log_path: PathBuf) -> impl Stream<Item = Option<String>> {
331-
channel(1, move |mut output| async move {
331+
channel(5, move |mut output| async move {
332332
loop {
333333
// Reduce the io load.
334334
tokio::time::sleep(Duration::from_millis(500)).await;

0 commit comments

Comments
 (0)