Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/services/cos/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,9 @@ pub struct CommonPrefix {
#[serde(default, rename_all = "PascalCase")]
pub struct ListObjectsOutputContent {
pub key: String,
pub last_modified: String,
#[serde(rename = "ETag")]
pub etag: Option<String>,
pub size: u64,
}

Expand Down Expand Up @@ -719,6 +722,23 @@ mod tests {
out.contents.iter().map(|v| v.size).collect::<Vec<u64>>(),
[9, 10],
);
assert_eq!(
out.contents
.iter()
.map(|v| v.last_modified.clone())
.collect::<Vec<String>>(),
["2015-07-01T02:11:19.775Z", "2015-07-01T02:11:19.775Z"],
);
assert_eq!(
out.contents
.iter()
.map(|v| v.etag.clone())
.collect::<Vec<Option<String>>>(),
[
Some("\"a72e382246ac83e86bd203389849e71d\"".to_string()),
Some("\"a72e382246ac83e86bd203389849e71d\"".to_string()),
],
);
assert_eq!(
out.common_prefixes
.iter()
Expand Down
8 changes: 7 additions & 1 deletion core/services/cos/src/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ impl oio::PageList for CosLister {
path = "/".to_string();
}

let meta = Metadata::new(EntryMode::from_path(&path)).with_content_length(object.size);
let mut meta =
Metadata::new(EntryMode::from_path(&path)).with_content_length(object.size);
meta.set_last_modified(object.last_modified.parse::<Timestamp>()?);
if let Some(etag) = object.etag {
meta.set_etag(&etag);
meta.set_content_md5(etag.trim_matches('"'));
}

let de = oio::Entry::with(path, meta);
ctx.entries.push_back(de);
Expand Down
Loading