Skip to content

Commit

Permalink
fix(services/s3): Accept List responses without ETag (#3478)
Browse files Browse the repository at this point in the history
* fix(services/s3): Accept List responses without ETag

* tests

* fixed lint issue
  • Loading branch information
amunra authored Nov 3, 2023
1 parent 303f6e5 commit 2653963
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions core/src/services/s3/pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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,
},
]
)
}
Expand Down

0 comments on commit 2653963

Please sign in to comment.