app: compute the download percentage with checked_div

The current clippy flags the `if total > 0` guard around the division as
`manual_checked_ops`, and `-D warnings` turns that into a failed build,
so nothing else in the app could be checked. `checked_div` says the same
thing without the lint.
This commit is contained in:
vhaudiquet committed 2026-11-19 23:20:17 +01:00
1 parent 70e896b3cb
commit 9f6a047867
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -695,7 +695,7 @@ impl App {
while let Ok(event) = rx.try_recv() { while let Ok(event) = rx.try_recv() {
match event { match event {
export::FetchEvent::Bytes { done, total } => { export::FetchEvent::Bytes { done, total } => {
let pct = if total > 0 { done * 100 / total } else { 0 }; let pct = (done * 100).checked_div(total).unwrap_or(0);
if self.ffmpeg_pct != Some(pct) { if self.ffmpeg_pct != Some(pct) {
self.ffmpeg_pct = Some(pct); self.ffmpeg_pct = Some(pct);
if self.ffmpeg_banner_showing() { if self.ffmpeg_banner_showing() {
+1 -1
View File
@@ -136,7 +136,7 @@ fn fetch_ffmpeg() {
let shown = std::cell::Cell::new(u64::MAX); let shown = std::cell::Cell::new(u64::MAX);
let result = export::fetch(|event| match event { let result = export::fetch(|event| match event {
export::FetchEvent::Bytes { done, total } => { export::FetchEvent::Bytes { done, total } => {
let pct = if total > 0 { done * 100 / total } else { 0 }; let pct = (done * 100).checked_div(total).unwrap_or(0);
if pct != shown.get() { if pct != shown.get() {
shown.set(pct); shown.set(pct);
println!("ffmpeg: {pct}%"); println!("ffmpeg: {pct}%");