Skip to content

Commit c42e244

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

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl ObjectStore for HdfsObjectStore {
338338
let status_stream = self
339339
.client
340340
.list_status_iter(
341-
&prefix.map(make_absolute_dir).unwrap_or("".to_string()),
341+
&prefix.map(make_absolute_dir).unwrap_or("/".to_string()),
342342
true,
343343
)
344344
.into_stream()

tests/test_object_store.rs

+5
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)