From 45a69ac003613a2ca21901551384a1d8061f77d5 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 23 Sep 2024 08:15:19 +0200 Subject: [PATCH] no panic on missing port --- ffplayout/src/main.rs | 7 ++++++- ffplayout/src/player/utils/folder.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ffplayout/src/main.rs b/ffplayout/src/main.rs index bcfc712c..97abf438 100644 --- a/ffplayout/src/main.rs +++ b/ffplayout/src/main.rs @@ -94,7 +94,12 @@ async fn main() -> std::io::Result<()> { let ip_port = conn.split(':').collect::>(); let addr = ip_port[0]; - let port = ip_port[1].parse::().unwrap(); + let port = ip_port + .get(1) + .ok_or(": needed!") + .map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))? + .parse::() + .unwrap(); let controllers = web::Data::from(channel_controllers.clone()); let auth_state = web::Data::new(SseAuthState { uuids: tokio::sync::Mutex::new(HashSet::new()), diff --git a/ffplayout/src/player/utils/folder.rs b/ffplayout/src/player/utils/folder.rs index d650f7c3..8a206e4e 100644 --- a/ffplayout/src/player/utils/folder.rs +++ b/ffplayout/src/player/utils/folder.rs @@ -154,7 +154,7 @@ impl Iterator for FolderSource { self.sort(); } - self.current_node = match self.manager.current_list.lock().unwrap().get(0) { + self.current_node = match self.manager.current_list.lock().unwrap().first() { Some(m) => m.clone(), None => return None, };