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 c0802f10e fix(services/fs): add content length and modified time to 
metadata (#7188)
c0802f10e is described below

commit c0802f10e3173649811ebff8d225ccfa35aebfbc
Author: Matthew Hambrecht <[email protected]>
AuthorDate: Mon Feb 23 05:41:25 2026 -0500

    fix(services/fs): add content length and modified time to metadata (#7188)
    
    add content length and modified time to metadata
    
    Co-authored-by: Matthew Hambrecht <[email protected]>
---
 core/services/fs/src/lister.rs | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/core/services/fs/src/lister.rs b/core/services/fs/src/lister.rs
index d2ccdbb4b..90aaf3075 100644
--- a/core/services/fs/src/lister.rs
+++ b/core/services/fs/src/lister.rs
@@ -68,14 +68,22 @@ impl oio::List for FsLister<tokio::fs::ReadDir> {
         );
 
         let ft = de.file_type().await.map_err(new_std_io_error)?;
-        let entry = if ft.is_dir() {
+        let (path, mode) = if ft.is_dir() {
             // Make sure we are returning the correct path.
-            oio::Entry::new(&format!("{rel_path}/"), 
Metadata::new(EntryMode::DIR))
+            (&format!("{rel_path}/"), EntryMode::DIR)
         } else if ft.is_file() {
-            oio::Entry::new(&rel_path, Metadata::new(EntryMode::FILE))
+            (&rel_path, EntryMode::FILE)
         } else {
-            oio::Entry::new(&rel_path, Metadata::new(EntryMode::Unknown))
+            (&rel_path, EntryMode::Unknown)
         };
-        Ok(Some(entry))
+
+        let de_metadata = de.metadata().await.map_err(new_std_io_error)?;
+        let metadata = Metadata::new(mode)
+            .with_content_length(de_metadata.len())
+            .with_last_modified(Timestamp::try_from(
+                de_metadata.modified().map_err(new_std_io_error)?,
+            )?);
+
+        Ok(Some(oio::Entry::new(path, metadata)))
     }
 }

Reply via email to