From 00c4e61ed926bd6e630102e8d4eee2b978efac73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Wed, 7 Jun 2023 13:06:44 +0200 Subject: [PATCH] udp: fix template error --- aquatic_udp/src/workers/swarm/storage.rs | 21 ++++++++++++++++++--- aquatic_udp/templates/statistics.html | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/aquatic_udp/src/workers/swarm/storage.rs b/aquatic_udp/src/workers/swarm/storage.rs index 9c78021..2c864e8 100644 --- a/aquatic_udp/src/workers/swarm/storage.rs +++ b/aquatic_udp/src/workers/swarm/storage.rs @@ -86,11 +86,21 @@ impl TorrentData { match (status, opt_removed_peer.is_some()) { // We added a new peer (PeerStatus::Leeching | PeerStatus::Seeding, false) => { - statistics_sender.try_send(StatisticsMessage::PeerAdded(peer_id)); + if let Err(_) = + statistics_sender.try_send(StatisticsMessage::PeerAdded(peer_id)) + { + // Should never happen in practice + ::log::error!("Couldn't send StatisticsMessage::PeerAdded"); + } } // We removed an existing peer (PeerStatus::Stopped, true) => { - statistics_sender.try_send(StatisticsMessage::PeerRemoved(peer_id)); + if let Err(_) = + statistics_sender.try_send(StatisticsMessage::PeerRemoved(peer_id)) + { + // Should never happen in practice + ::log::error!("Couldn't send StatisticsMessage::PeerRemoved"); + } } _ => (), } @@ -149,7 +159,12 @@ impl TorrentData { self.num_seeders -= 1; } if config.statistics.extended { - statistics_sender.try_send(StatisticsMessage::PeerRemoved(*peer_id)); + if let Err(_) = + statistics_sender.try_send(StatisticsMessage::PeerRemoved(*peer_id)) + { + // Should never happen in practice + ::log::error!("Couldn't send StatisticsMessage::PeerRemoved"); + } } } diff --git a/aquatic_udp/templates/statistics.html b/aquatic_udp/templates/statistics.html index 77463f6..0fe8930 100644 --- a/aquatic_udp/templates/statistics.html +++ b/aquatic_udp/templates/statistics.html @@ -267,7 +267,7 @@ {{ for value in peer_clients }} { value.0 } - { value.2 } + { value.1 } {{ endfor }}