diff --git a/native/hub/src/playback.rs b/native/hub/src/playback.rs index 4c3c62e86..3d470c3bd 100644 --- a/native/hub/src/playback.rs +++ b/native/hub/src/playback.rs @@ -1,4 +1,5 @@ use std::path::Path; +use std::path::PathBuf; use std::sync::Arc; use anyhow::{Context, Result}; @@ -29,20 +30,20 @@ use crate::{ pub fn files_to_playback_request( lib_path: &String, files: &[database::entities::media_files::Model], -) -> std::vec::Vec<(i32, std::path::PathBuf)> { +) -> Vec<(i32, PathBuf)> { files .iter() - .map(|file| { - let file_path = canonicalize( - Path::new(lib_path) - .join(&file.directory) - .join(&file.file_name), - ) - .unwrap(); - - (file.id, file_path) + .filter_map(|file| { + let file_path = Path::new(lib_path) + .join(&file.directory) + .join(&file.file_name); + + match canonicalize(&file_path) { + Ok(canonical_path) => Some((file.id, canonical_path)), + Err(_) => None, + } }) - .collect::>() + .collect() } pub async fn load_request(