Aitozi commented on code in PR #5005:
URL: https://github.com/apache/opendal/pull/5005#discussion_r1716303708
##########
core/src/services/fs/lister.rs:
##########
@@ -93,17 +103,61 @@ impl oio::BlockingList for FsLister<std::fs::ReadDir> {
// (no extra system calls needed), but some Unix platforms may
// require the equivalent call to symlink_metadata to learn about
// the target file type.
- let file_type = de.file_type().map_err(new_std_io_error)?;
- let entry = if file_type.is_file() {
- oio::Entry::new(&rel_path, Metadata::new(EntryMode::FILE))
- } else if file_type.is_dir() {
+ let default_meta = self.op.metakey() == Metakey::Mode;
+
+ let (metadata, is_dir) = if default_meta {
+ let ft = de.file_type().map_err(new_std_io_error)?;
+ get_metadata(self.op.metakey(), None, Some(ft))?
+ } else {
+ let fs_meta = de.metadata().map_err(new_std_io_error)?;
+ get_metadata(self.op.metakey(), Some(fs_meta), None)?
+ };
+
+ let p = if is_dir {
// Make sure we are returning the correct path.
- oio::Entry::new(&format!("{rel_path}/"),
Metadata::new(EntryMode::DIR))
+ &format!("{rel_path}/")
} else {
- oio::Entry::new(&rel_path, Metadata::new(EntryMode::Unknown))
+ &rel_path
};
- Ok(Some(entry))
+ Ok(Some(oio::Entry::new(p, metadata)))
}
}
+
+fn get_metadata(
Review Comment:
Get it, will follow your suggestion, thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]