diff --git a/daemon/src/diag.rs b/daemon/src/diag.rs index 3453c9c..9406304 100644 --- a/daemon/src/diag.rs +++ b/daemon/src/diag.rs @@ -289,19 +289,17 @@ impl DiagTask { self.stop(qmdl_store, Some(reason)).await; return; } - DiskSpaceCheck::Warning(mb) => { - if !self.low_space_warned { - self.low_space_warned = true; - warn!("Disk space low: {}MB remaining", mb); - self.notification_channel - .send(Notification::new( - NotificationType::Warning, - format!("Disk space low: {}MB free", mb), - Some(Duration::from_secs(30)), - )) - .await - .ok(); - } + DiskSpaceCheck::Warning(mb) if !self.low_space_warned => { + self.low_space_warned = true; + warn!("Disk space low: {}MB remaining", mb); + self.notification_channel + .send(Notification::new( + NotificationType::Warning, + format!("Disk space low: {}MB free", mb), + Some(Duration::from_secs(30)), + )) + .await + .ok(); } _ => {} } diff --git a/daemon/src/qmdl_store.rs b/daemon/src/qmdl_store.rs index acc4826..b57ddcf 100644 --- a/daemon/src/qmdl_store.rs +++ b/daemon/src/qmdl_store.rs @@ -216,7 +216,7 @@ impl RecordingStore { } // sort chronologically - manifest_entries.sort_by(|a, b| a.start_time.cmp(&b.start_time)); + manifest_entries.sort_by_key(|a| a.start_time); let mut store = RecordingStore { path: path.as_ref().to_path_buf(), diff --git a/daemon/src/stats.rs b/daemon/src/stats.rs index ba51d31..1c572ba 100644 --- a/daemon/src/stats.rs +++ b/daemon/src/stats.rs @@ -81,11 +81,12 @@ impl DiskStats { let free_kb = (stat.f_bfree as u64 * block_size / 1024) as usize; let available_kb = (stat.f_bavail as u64 * block_size / 1024) as usize; let used_kb = total_kb.saturating_sub(free_kb); - let used_percent = if stat.f_blocks > 0 { - format!("{}%", (stat.f_blocks - stat.f_bfree) * 100 / stat.f_blocks) - } else { - "0%".to_string() - }; + let used_percent = format!( + "{}%", + ((stat.f_blocks - stat.f_bfree) * 100) + .checked_div(stat.f_blocks) + .unwrap_or(0) + ); Ok(Self { partition: qmdl_path.to_string(), diff --git a/installer/src/util.rs b/installer/src/util.rs index c8e8a11..3868804 100644 --- a/installer/src/util.rs +++ b/installer/src/util.rs @@ -42,10 +42,7 @@ pub async fn telnet_send_command_with_output( let mut read_buf = Vec::new(); timeout(Duration::from_secs(10), async { - loop { - let Ok(byte) = reader.read_u8().await else { - break; - }; + while let Ok(byte) = reader.read_u8().await { read_buf.push(byte); // when we see this string we know the command is done and can terminate.