style: apply cargo fmt

This commit is contained in:
michel
2026-04-26 17:28:43 +02:00
parent 9d6a33da34
commit d06aa2d3de
4 changed files with 23 additions and 21 deletions
+4 -4
View File
@@ -245,13 +245,13 @@ impl PeerActor {
"[peer:{}] Place in queue response - file: {}, place: {}", "[peer:{}] Place in queue response - file: {}, place: {}",
username, filename, place username, filename, place
); );
if let Err(e) = if let Err(e) = self.client_channel.send(
self.client_channel.send(ClientOperation::PlaceInQueueUpdate { ClientOperation::PlaceInQueueUpdate {
username: username.clone(), username: username.clone(),
filename, filename,
place, place,
}) },
{ ) {
error!( error!(
"[peer:{}] failed to forward PlaceInQueueUpdate: {}", "[peer:{}] failed to forward PlaceInQueueUpdate: {}",
username, e username, e
+2 -3
View File
@@ -1066,9 +1066,8 @@ impl Client {
place, place,
} => match client_context.write_safe() { } => match client_context.write_safe() {
Ok(mut ctx) => { Ok(mut ctx) => {
let updated = ctx let updated =
.downloads ctx.downloads.update_queue_position(
.update_queue_position(
&username, &filename, place, &username, &filename, place,
); );
if !updated { if !updated {
+1 -4
View File
@@ -191,10 +191,7 @@ mod tests {
store.add(download); store.add(download);
assert!(store.update_queue_position("peer", "song.mp3", 42)); assert!(store.update_queue_position("peer", "song.mp3", 42));
assert_eq!( assert_eq!(store.get_by_token(1).unwrap().queue_position, Some(42));
store.get_by_token(1).unwrap().queue_position,
Some(42)
);
assert!(!store.update_queue_position("peer", "missing.mp3", 1)); assert!(!store.update_queue_position("peer", "missing.mp3", 1));
assert!(!store.update_queue_position("other", "song.mp3", 1)); assert!(!store.update_queue_position("other", "song.mp3", 1));
+14 -8
View File
@@ -1,7 +1,7 @@
use crate::models::DownloadEntry; use crate::models::DownloadEntry;
use crate::ui::{ use crate::ui::{
border_style, border_type, dimmed_style, error_style, format_bytes, border_style, border_type, dimmed_style, error_style, format_bytes,
format_progress_bar, format_speed, info_style, inactive_style, format_progress_bar, format_speed, inactive_style, info_style,
primary_style, success_style, warning_style, primary_style, success_style, warning_style,
}; };
use ratatui::{ use ratatui::{
@@ -29,12 +29,10 @@ pub fn render_download_info_pane(
.title("[Info]"); .title("[Info]");
let Some(entry) = selected else { let Some(entry) = selected else {
let paragraph = Paragraph::new( let paragraph = Paragraph::new(Line::from(Span::styled(
Line::from(Span::styled(
"Select a download for details.", "Select a download for details.",
dimmed_style(), dimmed_style(),
)), )))
)
.block(block); .block(block);
frame.render_widget(paragraph, area); frame.render_widget(paragraph, area);
return; return;
@@ -42,7 +40,9 @@ pub fn render_download_info_pane(
let lines = build_info_lines(&entry.download); let lines = build_info_lines(&entry.download);
let paragraph = Paragraph::new(lines).block(block).wrap(Wrap { trim: false }); let paragraph = Paragraph::new(lines)
.block(block)
.wrap(Wrap { trim: false });
frame.render_widget(paragraph, area); frame.render_widget(paragraph, area);
} }
@@ -121,7 +121,10 @@ fn build_info_lines(
} => { } => {
lines.push(Line::from("")); lines.push(Line::from(""));
push_progress_lines(&mut lines, *bytes_downloaded, *total_bytes); push_progress_lines(&mut lines, *bytes_downloaded, *total_bytes);
lines.push(label_value("Speed", &format_speed(*speed_bytes_per_sec))); lines.push(label_value(
"Speed",
&format_speed(*speed_bytes_per_sec),
));
if *speed_bytes_per_sec > 0.0 && *total_bytes > *bytes_downloaded { if *speed_bytes_per_sec > 0.0 && *total_bytes > *bytes_downloaded {
let remaining = *total_bytes - *bytes_downloaded; let remaining = *total_bytes - *bytes_downloaded;
@@ -194,7 +197,10 @@ fn split_filename(path: &str) -> (String, String) {
let normalized = path.replace('\\', "/"); let normalized = path.replace('\\', "/");
if let Some(idx) = normalized.rfind('/') { if let Some(idx) = normalized.rfind('/') {
let (parent, basename) = normalized.split_at(idx); let (parent, basename) = normalized.split_at(idx);
(basename.trim_start_matches('/').to_string(), parent.to_string()) (
basename.trim_start_matches('/').to_string(),
parent.to_string(),
)
} else { } else {
(normalized, String::new()) (normalized, String::new())
} }