diff --git a/lib/vfs/src/webc_volume_fs.rs b/lib/vfs/src/webc_volume_fs.rs index daa716679aa..77666fbf122 100644 --- a/lib/vfs/src/webc_volume_fs.rs +++ b/lib/vfs/src/webc_volume_fs.rs @@ -55,7 +55,7 @@ impl FileSystem for WebcVolumeFileSystem { return Err(FsError::BaseNotDirectory); } - let path = dbg!(normalize(path)).map_err(|_| FsError::InvalidInput)?; + let path = normalize(path).map_err(|_| FsError::InvalidInput)?; let mut entries = Vec::new(); @@ -123,7 +123,7 @@ impl FileSystem for WebcVolumeFileSystem { } fn metadata(&self, path: &Path) -> Result { - let path = dbg!(normalize(path)).map_err(|_| FsError::InvalidInput)?; + let path = normalize(path).map_err(|_| FsError::InvalidInput)?; self.volume() .metadata(path) @@ -293,10 +293,19 @@ fn compat_meta(meta: webc::compat::Metadata) -> Metadata { /// Normalize a [`Path`] into a [`PathSegments`], dealing with things like `..` /// and skipping `.`'s. -#[tracing::instrument(level = "trace", err)] fn normalize(path: &Path) -> Result { // normalization is handled by the ToPathSegments impl for Path - path.to_path_segments() + let result = path.to_path_segments(); + + if let Err(e) = &result { + tracing::debug!( + error = e as &dyn std::error::Error, + path=%path.display(), + "Unable to normalize a path", + ); + } + + result } #[cfg(test)] @@ -341,10 +350,6 @@ mod tests { ), (r"\\.\c:\temp\test-file.txt", &["temp", "test-file.txt"]), (r"\\?\c:\temp\test-file.txt", &["temp", "test-file.txt"]), - ( - r"\\.\UNC\LOCALHOST\c$\temp\test-file.txt", - &["temp", "test-file.txt"], - ), ( r"\\127.0.0.1\c$\temp\test-file.txt", &["temp", "test-file.txt"], @@ -357,28 +362,16 @@ mod tests { for (path, expected) in inputs { let normalized = normalize(path.as_ref()).unwrap(); - assert_eq!(normalized, expected.to_path_segments().unwrap()); + assert_eq!(normalized, expected.to_path_segments().unwrap(), "{}", path); } } #[test] fn invalid_paths() { - let paths = [ - (".", PathSegmentError::NotAbsolute), - ("..", PathSegmentError::NotAbsolute), - ("./file.txt", PathSegmentError::NotAbsolute), - ( - "", - if cfg!(windows) { - PathSegmentError::Empty - } else { - PathSegmentError::NotAbsolute - }, - ), - ]; + let paths = [".", "..", "./file.txt", ""]; - for (path, err) in paths { - assert_eq!(normalize(path.as_ref()).unwrap_err(), err, "{path}"); + for path in paths { + assert!(normalize(path.as_ref()).is_err(), "{}", path); } }