Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fs): expose the metadata for fs services #5005

Merged
merged 7 commits into from
Aug 14, 2024

Conversation

Aitozi
Copy link
Contributor

@Aitozi Aitozi commented Aug 13, 2024

Which issue does this PR close?

Part of #4746.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@Xuanwo Xuanwo changed the title fix(fs): expose the metadata for fs services feat(fs): expose the metadata for fs services Aug 13, 2024
get_metadata(self.op.metakey(), Some(fs_meta), None)?
};

let p = if is_dir {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need is_dir, we can use metadata.mode() to check.

}
}

fn get_metadata(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I feel like this helper function is a bit overdesigned. How about writing the logic directly? OpenDAL doesn't have a code style yet, but we tend to optimize for readability and avoid unnecessary abstraction, which can help a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to share the same logic in the List and BlockingList

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to share the same logic in the List and BlockingList

Yes, I understand your motivation. However, sharing code that is used only twice is not encouraged in OpenDAL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it, will follow your suggestion, thanks

fs_meta: Option<std::fs::Metadata>,
file_type: Option<FileType>,
) -> Result<(Metadata, bool)> {
let ft = if let Some(t) = fs_meta.as_ref() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we expand logic, we don't need this.

let contains_metakey = |k| metakey.contains(k) || metakey.contains(Metakey::Complete);
let fs_meta = fs_meta.unwrap();

if contains_metakey(Metakey::ContentLength) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to check the meta key. If we have sent metadata syscall, we can fill in any known data.

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others LGTM, thank you!

@@ -93,17 +116,38 @@ 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 default_meta = self.op.metakey() == Metakey::Mode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, please remove the upper comment before de.file_type().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done~

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Xuanwo Xuanwo merged commit 87e98ef into apache:main Aug 14, 2024
220 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants