Skip to content

Commit 0677b69

Browse files
author
Matthew Hambrecht
committed
add content length and modified time to metadata
1 parent 8658906 commit 0677b69

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

core/services/fs/src/lister.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,22 @@ impl oio::List for FsLister<tokio::fs::ReadDir> {
6868
);
6969

7070
let ft = de.file_type().await.map_err(new_std_io_error)?;
71-
let entry = if ft.is_dir() {
71+
let (path, mode) = if ft.is_dir() {
7272
// Make sure we are returning the correct path.
73-
oio::Entry::new(&format!("{rel_path}/"), Metadata::new(EntryMode::DIR))
73+
(&format!("{rel_path}/"), EntryMode::DIR)
7474
} else if ft.is_file() {
75-
oio::Entry::new(&rel_path, Metadata::new(EntryMode::FILE))
75+
(&rel_path, EntryMode::FILE)
7676
} else {
77-
oio::Entry::new(&rel_path, Metadata::new(EntryMode::Unknown))
77+
(&rel_path, EntryMode::Unknown)
7878
};
79-
Ok(Some(entry))
79+
80+
let de_metadata = de.metadata().await.map_err(new_std_io_error)?;
81+
let metadata = Metadata::new(mode)
82+
.with_content_length(de_metadata.len())
83+
.with_last_modified(Timestamp::try_from(
84+
de_metadata.modified().map_err(new_std_io_error)?,
85+
)?);
86+
87+
Ok(Some(oio::Entry::new(path, metadata)))
8088
}
8189
}

0 commit comments

Comments
 (0)