amunra opened a new issue, #6805:
URL: https://github.com/apache/opendal/issues/6805
### Describe the bug
The function documents "This function only reads the immediate children of
the specified directory.", but it looks like it's also listing the current
directory.
### Steps to Reproduce
```rust
use opendal::{Operator, services::Fs};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a temporary directory for our operations
let temp_dir = std::env::temp_dir().join("opendal_example");
std::fs::create_dir_all(&temp_dir)?;
println!("Using temp directory: {}", temp_dir.display());
println!();
// Initialize OpenDAL with filesystem service
let builder = Fs::default();
let builder = builder.root(&temp_dir.to_string_lossy());
let op: Operator = Operator::new(builder)?.finish();
// Create the directory structure and files
println!("Creating files and directories...");
// Create files in a/
op.write("a/a", "content").await?;
// Create files in a/ab/
op.write("a/ab/aba", "content").await?;
op.write("a/ab/abb", "content").await?;
// Create files in b/
op.write("b/ba", "content").await?;
op.write("b/bb", "content").await?;
println!("Files created successfully!");
println!();
// List root directory
println!("Listing '/':");
println!("{}", "=".repeat(50));
let entries = op.list("/").await?;
for entry in entries {
let path = entry.path();
let metadata = entry.metadata();
let entry_type = if metadata.is_dir() { "DIR " } else { "FILE" };
println!(" [{}] {}", entry_type, path);
}
println!();
// List a/ directory
println!("Listing '/a/':");
println!("{}", "=".repeat(50));
let entries = op.list("/a/").await?;
for entry in entries {
let path = entry.path();
let metadata = entry.metadata();
let entry_type = if metadata.is_dir() { "DIR " } else { "FILE" };
println!(" [{}] {}", entry_type, path);
}
println!();
// List a/ab/ directory
println!("Listing '/a/ab/':");
println!("{}", "=".repeat(50));
let entries = op.list("/a/ab/").await?;
for entry in entries {
let path = entry.path();
let metadata = entry.metadata();
let entry_type = if metadata.is_dir() { "DIR " } else { "FILE" };
println!(" [{}] {}", entry_type, path);
}
println!();
println!("Done!");
Ok(())
}
```
Which outputs:
```
Creating files and directories...
Files created successfully!
Listing '/':
==================================================
[DIR ] /
[DIR ] a/
[DIR ] b/
Listing '/a/':
==================================================
[DIR ] a/
[DIR ] a/ab/
[FILE] a/a
Listing '/a/ab/':
==================================================
[DIR ] a/ab/
[FILE] a/ab/abb
[FILE] a/ab/aba
Done!
```
### Expected Behavior
Expecting the path specified to `operator.list(..)` NOT to be included. In
other words, the test program above should output:
```
Creating files and directories...
Files created successfully!
Listing '/':
==================================================
[DIR ] a/
[DIR ] b/
Listing '/a/':
==================================================
[DIR ] a/ab/
[FILE] a/a
Listing '/a/ab/':
==================================================
[FILE] a/ab/abb
[FILE] a/ab/aba
Done!
```
### Additional Context
OpenDAL 0.54.1
We were previously running OpenDAL 0.42.0 which did not have this bug: This
is a regression.
### Are you willing to submit a PR to fix this bug?
- [ ] Yes, I would like to submit a PR.
--
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]