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 fb9c92fc15976a6ce770a843cd60a8c0c03b256f
Author: Xuanwo <[email protected]>
AuthorDate: Wed Nov 22 19:11:56 2023 +0800

    Fix gdrive
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/services/gdrive/backend.rs | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/core/src/services/gdrive/backend.rs 
b/core/src/services/gdrive/backend.rs
index 8f82ede86..d89e67ea2 100644
--- a/core/src/services/gdrive/backend.rs
+++ b/core/src/services/gdrive/backend.rs
@@ -85,15 +85,19 @@ impl Accessor for GdriveBackend {
 
         let resp = self.core.gdrive_stat(path).await?;
 
-        let status = resp.status();
+        if resp.status() != StatusCode::OK {
+            return Err(parse_error(resp).await?);
+        }
 
-        match status {
-            StatusCode::OK => {
-                let meta = 
self.parse_metadata(resp.into_body().bytes().await?)?;
-                Ok(RpStat::new(meta))
-            }
-            _ => Err(parse_error(resp).await?),
+        let meta = self.parse_metadata(resp.into_body().bytes().await?)?;
+        if path.ends_with('/') && meta.mode() == EntryMode::FILE {
+            return Err(Error::new(
+                ErrorKind::NotFound,
+                "given path is not a directory",
+            ));
         }
+
+        Ok(RpStat::new(meta))
     }
 
     async fn create_dir(&self, path: &str, _args: OpCreateDir) -> 
Result<RpCreateDir> {

Reply via email to