alamb commented on code in PR #2269:
URL: https://github.com/apache/arrow-rs/pull/2269#discussion_r935581065
##########
object_store/src/local.rs:
##########
@@ -170,6 +170,17 @@ impl From<Error> for super::Error {
///
/// If not called from a tokio context, this will perform IO on the current
thread with
/// no additional complexity or overheads
+///
+/// # Symlinks
Review Comment:
👍
##########
object_store/src/local.rs:
##########
@@ -1030,6 +1047,124 @@ mod tests {
}
}
+ async fn check_list(
+ integration: &LocalFileSystem,
+ prefix: Option<&Path>,
+ expected: &[&str],
+ ) {
+ let result: Vec<_> = integration
+ .list(prefix)
+ .await
+ .unwrap()
+ .try_collect()
+ .await
+ .unwrap();
+
+ let mut strings: Vec<_> = result.iter().map(|x|
x.location.as_ref()).collect();
+ strings.sort_unstable();
+ assert_eq!(&strings, expected)
+ }
+
+ #[tokio::test]
+ #[cfg(target_family = "unix")]
+ async fn test_symlink() {
+ let root = TempDir::new().unwrap();
+ let integration =
LocalFileSystem::new_with_prefix(root.path()).unwrap();
+
+ let subdir = root.path().join("a");
+ std::fs::create_dir(&subdir).unwrap();
+ let file = subdir.join("file.parquet");
+ std::fs::write(file, "test").unwrap();
+
+ check_list(&integration, None, &["a/file.parquet"]).await;
+ integration
+ .head(&Path::from("a/file.parquet"))
+ .await
+ .unwrap();
+
+ // Follow out of tree symlink
Review Comment:
love the comments in this test
##########
object_store/src/local.rs:
##########
@@ -214,10 +225,11 @@ impl LocalFileSystem {
impl Config {
/// Return filesystem path of the given location
- fn path_to_filesystem(&self, location: &Path) ->
Result<std::path::PathBuf> {
+ fn path_to_filesystem(&self, location: &Path) -> Result<PathBuf> {
let mut url = self.root.clone();
url.path_segments_mut()
.expect("url path")
+ .pop_if_empty()
Review Comment:
```suggestion
// technically not necessary as Path ignores empty segments
// but avoids creating paths with "//" which look odd in error
messages.
.pop_if_empty()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]