Skip to content

Commit 9ce9e0a

Browse files
rtylerKimahriman
authored andcommitted
fix: list(None) is logically equivalent to list("/") (#19)
Signed-off-by: R. Tyler Croy <[email protected]>
1 parent 2313036 commit 9ce9e0a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl ObjectStore for HdfsObjectStore {
330330
let status_stream = self
331331
.client
332332
.list_status_iter(
333-
&prefix.map(make_absolute_dir).unwrap_or("".to_string()),
333+
&prefix.map(make_absolute_dir).unwrap_or("/".to_string()),
334334
true,
335335
)
336336
.into_stream()

tests/test_object_store.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ mod test {
7979
assert_eq!(list.len(), 1);
8080
assert_eq!(list[0].as_ref().unwrap().location, Path::from("/testfile"));
8181

82+
// A list of None should be logically equivalent to /
83+
let list: Vec<object_store::Result<ObjectMeta>> = store.list(None).collect().await;
84+
assert_eq!(list.len(), 1);
85+
assert_eq!(list[0].as_ref().unwrap().location, Path::from("/testfile"));
86+
8287
// Listing of a prefix that doesn't exist should return an empty result, not an error
8388
assert_eq!(
8489
store.list(Some(&Path::from("/doesnt/exist"))).count().await,

0 commit comments

Comments
 (0)