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

Use proper flag semantics instead of passing around raw integers #69

Merged
merged 1 commit into from
May 18, 2023

Conversation

dralley
Copy link
Collaborator

@dralley dralley commented Jan 1, 2023

closes #52

@dralley dralley changed the title Use proper flag semantics instead of passing around raw integers [WIP] Use proper flag semantics instead of passing around raw integers Jan 1, 2023
@dralley
Copy link
Collaborator Author

dralley commented Jan 1, 2023

@drahnr I think that this line might logically unsound, because these flags are not necessarily mutually exclusive. I'm not 100% sure. Thoughts?

category: FileCategory::from_u32(flags).unwrap_or_default(),

@dralley
Copy link
Collaborator Author

dralley commented Jan 10, 2023

Yes, supposedly %config(missingok) and %config(noreplace) are valid in combination

@dralley dralley mentioned this pull request Apr 14, 2023
5 tasks
@dralley dralley force-pushed the flag-semantics branch 2 times, most recently from 42e204f to 3db85ac Compare May 18, 2023 04:39
@@ -819,7 +821,7 @@ impl RPMPackageMetadata {
mode: mode.into(),
modified_at: utc.timestamp_opt(mtime as i64, 0u32).unwrap(), // shouldn't fail as we are using 0 nanoseconds
digest,
category: FileCategory::from_u32(flags).unwrap_or_default(),
flags: FileFlags::from_bits(flags).expect("Unexpected rpm file flags found"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be an error, since there it's within a try_fold anyways, panic seems unnecessary.

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

I like it, but we should avoid any panic-ing behavior in parsing packages, regardless if incoherent or not.

@dralley
Copy link
Collaborator Author

dralley commented May 18, 2023

FWIW, while it's still drafted I don't necessarily expect a review, still making some changes

@dralley dralley marked this pull request as ready for review May 18, 2023 20:10
@dralley dralley changed the title [WIP] Use proper flag semantics instead of passing around raw integers Use proper flag semantics instead of passing around raw integers May 18, 2023
@dralley dralley force-pushed the flag-semantics branch 2 times, most recently from f3945ec to 3f0c3fd Compare May 18, 2023 20:16
let algorithm = self.get_file_digest_algorithm().unwrap_or_default();
let algorithm = self
.get_file_digest_algorithm()
.unwrap_or(DigestAlgorithm::Md5);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Change: deleted Default impl for DigestAlgorithm as it should probably be contextual

Change: renamed a few fields named after sense to flags

@dralley dralley merged commit 66bffe0 into rpm-rs:master May 18, 2023
@dralley dralley deleted the flag-semantics branch May 18, 2023 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use proper flag semantics instead of passing around integers
2 participants