fix:fixed divide by zero panic when download size is unknown

This commit is contained in:
2024-11-03 15:36:26 -07:00
parent 8d7cb63c7a
commit 93d78701ce
+5 -1
View File
@@ -192,7 +192,11 @@ fn draw_downloads_context(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
size, size,
.. ..
} = &downloads_vec[i]; } = &downloads_vec[i];
let percent = 1f64 - (*sizeleft as f64 / *size as f64); let percent = if *size == 0 {
0.0
} else {
1f64 - (*sizeleft as f64 / *size as f64)
};
let download_gauge = line_gauge_with_title(title, percent); let download_gauge = line_gauge_with_title(title, percent);
f.render_widget(download_gauge, download_item_areas[i]); f.render_widget(download_gauge, download_item_areas[i]);