-
-
Notifications
You must be signed in to change notification settings - Fork 366
Split out convenience methods from ModuleWriter trait #2842
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
base: main
Are you sure you want to change the base?
Conversation
src/module_writer.rs
Outdated
| let source = fs::read_link(file.path())?; | ||
| writer.add_file_with_permissions( | ||
| relative, | ||
| source.parent().unwrap(), | ||
| mode, | ||
| )?; | ||
| writer.add_file_infer_permissions(relative, file.path())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only change I'm uncertain about. I'm passing file.path() here as the source so that the permission can be checked, but previously the code used to pass in the parent directory as the source. It's not clear to me why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this either. cc @konstin
f56cc44 to
811f7fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the ModuleWriter trait to improve its design by separating the core implementation method from convenience methods. The main method now accepts impl Read instead of byte slices, enabling streaming data processing.
- Split
ModuleWritertrait into a core trait with one method (add_data) and an extension trait (ModuleWriterExt) with convenience methods - Replaced byte slice parameters with
impl Readto support streaming - Introduced
StreamSha256for calculating hashes during streaming operations - Simplified permission handling to binary executable/non-executable flags (
0o755/0o644)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/module_writer.rs | Core refactoring: split trait into ModuleWriter and ModuleWriterExt, changed API to use impl Read, added StreamSha256 struct for streaming hash calculation, simplified permission handling |
| src/source_distribution.rs | Updated all calls to use new add_data and add_file APIs with boolean executable parameter |
| src/build_context.rs | Updated imports to include ModuleWriterExt and adapted method calls to new API |
| tests/common/metadata.rs | Updated mock implementation to match new ModuleWriter trait signature |
| Changelog.md | Added changelog entry for the refactoring |
811f7fc to
e25fe76
Compare
6b3ad03 to
64f8ffb
Compare
006dfe4 to
5fe2cbe
Compare
5fe2cbe to
fd48219
Compare
|
@messense I can back out the change adding |
I was thinking that the convenience methods with default implementations available on
ModuleWritershouldn't really be overridden and that implementers ofModuleWritershould only focus on the one primary method. In order to enforce that separation, this PR moves all the convenience methods into aModuleWriterExttrait that has a blanket implementation for allModuleWriters.In addition to that, the following related changes are included:
ModuleWriterto accept animpl Readinstead of a byte sliceimpl Read, add aStreamSha256struct that calculates the hash as the data is streamed to the underlying Writer0o755or0o644)The PR is structured so that the individual commits can be reviewed to ensure that there are no behavioral changes.