DCjanus commented on code in PR #2206:
URL: 
https://github.com/apache/incubator-opendal/pull/2206#discussion_r1186660927


##########
core/src/services/s3/backend.rs:
##########
@@ -1017,22 +1018,27 @@ impl Accessor for S3Backend {
     async fn stat(&self, path: &str, args: OpStat) -> Result<RpStat> {
         // Stat root always returns a DIR.
         if path == "/" {
+            // TODO: check if bucket exists
             return Ok(RpStat::new(Metadata::new(EntryMode::DIR)));
         }
 
-        let resp = self
-            .core
-            .s3_head_object(path, args.if_none_match(), args.if_match())
-            .await?;
-
-        let status = resp.status();
-
-        match status {
-            StatusCode::OK => parse_into_metadata(path, 
resp.headers()).map(RpStat::new),
-            StatusCode::NOT_FOUND if path.ends_with('/') => {
+        if path.ends_with('/') {
+            let (_, mut pager) = self.list(path, 
OpList::default().with_limit(1)).await?;

Review Comment:
   > Please call `list_objects` directly instead.
   
   
[s3_list_objects](https://github.com/apache/incubator-opendal/blob/1ff1b7b3e2b13c66832285cc993c93fc21c0538f/core/src/services/s3/core.rs#L449)
 return a response object, and we have to parse it with a lot of duplicate, 
while S3Pager already provides implementation.
   
   Is there any suggestion to avoid repeat it, and less break to code structure.



-- 
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]

Reply via email to