This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 26539633e fix(services/s3): Accept List responses without ETag (#3478)
26539633e is described below

commit 26539633e96bd289fa2be65a42f4727d85d47fd0
Author: Adam Cimarosti <[email protected]>
AuthorDate: Fri Nov 3 23:47:27 2023 +0000

    fix(services/s3): Accept List responses without ETag (#3478)
    
    * fix(services/s3): Accept List responses without ETag
    
    * tests
    
    * fixed lint issue
---
 core/src/services/s3/pager.rs | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/core/src/services/s3/pager.rs b/core/src/services/s3/pager.rs
index 3c5b15ed0..1525aa4ab 100644
--- a/core/src/services/s3/pager.rs
+++ b/core/src/services/s3/pager.rs
@@ -126,8 +126,10 @@ impl oio::Page for S3Pager {
 
             let mut meta = Metadata::new(EntryMode::FILE);
 
-            meta.set_etag(&object.etag);
-            meta.set_content_md5(object.etag.trim_matches('"'));
+            if let Some(etag) = &object.etag {
+                meta.set_etag(etag);
+                meta.set_content_md5(etag.trim_matches('"'));
+            }
             meta.set_content_length(object.size);
 
             // object.last_modified provides more precious time that contains
@@ -168,7 +170,7 @@ struct OutputContent {
     size: u64,
     last_modified: String,
     #[serde(rename = "ETag")]
-    etag: String,
+    etag: Option<String>,
 }
 
 #[derive(Default, Debug, Eq, PartialEq, Deserialize)]
@@ -205,6 +207,11 @@ mod tests {
     <Size>100</Size>
     <StorageClass>STANDARD</StorageClass>
   </Contents>
+  <Contents>
+    <Key>photos/2008</Key>
+    <LastModified>2016-05-30T23:51:29.000Z</LastModified>
+    <Size>42</Size>
+  </Contents>
 
   <CommonPrefixes>
     <Prefix>photos/2006/February/</Prefix>
@@ -232,15 +239,21 @@ mod tests {
                 OutputContent {
                     key: "photos/2006".to_string(),
                     size: 56,
-                    etag: "\"d41d8cd98f00b204e9800998ecf8427e\"".to_string(),
+                    etag: 
Some("\"d41d8cd98f00b204e9800998ecf8427e\"".to_string()),
                     last_modified: "2016-04-30T23:51:29.000Z".to_string(),
                 },
                 OutputContent {
                     key: "photos/2007".to_string(),
                     size: 100,
                     last_modified: "2016-04-30T23:51:29.000Z".to_string(),
-                    etag: "\"d41d8cd98f00b204e9800998ecf8427e\"".to_string(),
-                }
+                    etag: 
Some("\"d41d8cd98f00b204e9800998ecf8427e\"".to_string()),
+                },
+                OutputContent {
+                    key: "photos/2008".to_string(),
+                    size: 42,
+                    last_modified: "2016-05-30T23:51:29.000Z".to_string(),
+                    etag: None,
+                },
             ]
         )
     }

Reply via email to