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 238b08128213fb01809a0b2643b929ce36cd1f4e Author: Xuanwo <[email protected]> AuthorDate: Wed Nov 22 19:02:09 2023 +0800 Fix dropbox Signed-off-by: Xuanwo <[email protected]> --- core/src/services/dropbox/backend.rs | 13 ++++++++++--- core/src/services/fs/backend.rs | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/services/dropbox/backend.rs b/core/src/services/dropbox/backend.rs index 78a552141..421e31501 100644 --- a/core/src/services/dropbox/backend.rs +++ b/core/src/services/dropbox/backend.rs @@ -152,6 +152,7 @@ impl Accessor for DropboxBackend { if path == "/" { return Ok(RpStat::new(Metadata::new(EntryMode::DIR))); } + let resp = self.core.dropbox_get_metadata(path).await?; let status = resp.status(); match status { @@ -164,6 +165,15 @@ impl Accessor for DropboxBackend { "folder" => EntryMode::DIR, _ => EntryMode::Unknown, }; + + // Return not found if the path ends with `/` but meta is dir. + if path.ends_with('/') && entry_mode == EntryMode::FILE { + return Err(Error::new( + ErrorKind::NotFound, + "given path is not a directory", + )); + } + let mut metadata = Metadata::new(entry_mode); // Only set last_modified and size if entry_mode is FILE, because Dropbox API // returns last_modified and size only for files. @@ -184,9 +194,6 @@ impl Accessor for DropboxBackend { } Ok(RpStat::new(metadata)) } - StatusCode::NOT_FOUND if path.ends_with('/') => { - Ok(RpStat::new(Metadata::new(EntryMode::DIR))) - } _ => Err(parse_error(resp).await?), } } diff --git a/core/src/services/fs/backend.rs b/core/src/services/fs/backend.rs index 0cbea48f6..1a661e842 100644 --- a/core/src/services/fs/backend.rs +++ b/core/src/services/fs/backend.rs @@ -380,7 +380,7 @@ impl Accessor for FsBackend { let meta = tokio::fs::metadata(&p).await.map_err(new_std_io_error)?; - // Return not found if the path ends with `/` but meta is dir. + // Return not found if the path ends with `/` but meta is file. if !meta.is_dir() && path.ends_with('/') { return Err(Error::new( ErrorKind::NotFound,
