From 17057accc2a6e9169a54836a363f339795e60d37 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sun, 3 Dec 2023 22:22:44 -0500 Subject: [PATCH] Fix playlist filepath generation to ignore already-absolute paths --- interpreter/src/processing/filesystem.rs | 30 ++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/interpreter/src/processing/filesystem.rs b/interpreter/src/processing/filesystem.rs index cc55516..3856b42 100644 --- a/interpreter/src/processing/filesystem.rs +++ b/interpreter/src/processing/filesystem.rs @@ -395,14 +395,30 @@ impl FilesystemExecutor { let path = path.as_ref(); index += 1; let item_path = if let Some(parent) = path.parent() { - let joined_path = parent.join(&segment.uri); - if let Some(s) = joined_path.to_str() { - s.to_owned() + if segment.uri.starts_with('/') { + format!("file://{}", segment.uri) + } else if segment.uri.starts_with("file:///") { + segment.uri.clone() + } else if segment.uri.starts_with("file://") { + let joined_path = parent.join(&segment.uri.strip_prefix("file://").unwrap()); + if let Some(s) = joined_path.to_str() { + s.to_owned() + } else { + return Some(Err(RuntimeMsg(format!( + "Failed to convert path to string for `{}`", + joined_path.display() + )))); + } } else { - return Some(Err(RuntimeMsg(format!( - "Failed to convert path to string for `{}`", - joined_path.display() - )))); + let joined_path = parent.join(&segment.uri); + if let Some(s) = joined_path.to_str() { + s.to_owned() + } else { + return Some(Err(RuntimeMsg(format!( + "Failed to convert path to string for `{}`", + joined_path.display() + )))); + } } } else { segment.uri.clone()