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/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new fa08fbeccc feat(services/ftp): List dir shows last modified timestamp
(#5213)
fa08fbeccc is described below
commit fa08fbeccc56b59995173a6c57b1cb497449679c
Author: Erick Guan <[email protected]>
AuthorDate: Sun Oct 20 18:29:09 2024 +0200
feat(services/ftp): List dir shows last modified timestamp (#5213)
Co-authored-by: Erick Guan <[email protected]>
---
core/src/services/ftp/lister.rs | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/core/src/services/ftp/lister.rs b/core/src/services/ftp/lister.rs
index c3625a2eed..6dedc8f455 100644
--- a/core/src/services/ftp/lister.rs
+++ b/core/src/services/ftp/lister.rs
@@ -49,17 +49,22 @@ impl oio::List for FtpLister {
let path = self.path.to_string() + de.name();
+ let mut meta = if de.is_file() {
+ Metadata::new(EntryMode::FILE)
+ } else if de.is_directory() {
+ Metadata::new(EntryMode::DIR)
+ } else {
+ Metadata::new(EntryMode::Unknown)
+ };
+ meta.set_content_length(de.size() as u64);
+ meta.set_last_modified(de.modified().into());
+
let entry = if de.is_file() {
- oio::Entry::new(
- &path,
- Metadata::new(EntryMode::FILE)
- .with_content_length(de.size() as u64)
- .with_last_modified(de.modified().into()),
- )
+ oio::Entry::new(&path, meta)
} else if de.is_directory() {
- oio::Entry::new(&format!("{}/", &path),
Metadata::new(EntryMode::DIR))
+ oio::Entry::new(&format!("{}/", &path), meta)
} else {
- oio::Entry::new(&path, Metadata::new(EntryMode::Unknown))
+ oio::Entry::new(&path, meta)
};
Ok(Some(entry))