This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch fix-stat in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit e9e9c7fd21c5ee7887dcaafb86c6cbd2d497ea09 Author: Xuanwo <[email protected]> AuthorDate: Wed Nov 22 19:18:06 2023 +0800 Fix hdfs Signed-off-by: Xuanwo <[email protected]> --- core/src/services/hdfs/backend.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/services/hdfs/backend.rs b/core/src/services/hdfs/backend.rs index ea857d4f6..645e27cfa 100644 --- a/core/src/services/hdfs/backend.rs +++ b/core/src/services/hdfs/backend.rs @@ -323,6 +323,14 @@ impl Accessor for HdfsBackend { let meta = self.client.metadata(&p).map_err(new_std_io_error)?; + // Return not found if the path ends with `/` but meta is dir. + if path.ends_with('/') && meta.is_file() { + return Err(Error::new( + ErrorKind::NotFound, + "given path is not a directory", + )); + } + let mode = if meta.is_dir() { EntryMode::DIR } else if meta.is_file() { @@ -492,6 +500,14 @@ impl Accessor for HdfsBackend { let meta = self.client.metadata(&p).map_err(new_std_io_error)?; + // Return not found if the path ends with `/` but meta is dir. + if path.ends_with('/') && meta.is_file() { + return Err(Error::new( + ErrorKind::NotFound, + "given path is not a directory", + )); + } + let mode = if meta.is_dir() { EntryMode::DIR } else if meta.is_file() {
