Add file_mode to set file permissions
#6
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Addressed
#5
Proposed Changes
Adds a
file_modemethod to the builder to set file permissions in octal format. For example to set restrictive permissions:This also sets compressed files to these permissions as well.
This PR also contains a small architectural change (using
selfmore liberally) which made a few things easier for me.Considerations
Note that technically any
u32value will be accepted, even if it would break file permissions. For example.file_mode(600)is not equivalent to `.file_mode(0o600). It is highly recommended to use octal format otherwise you might get unexpected file permissions. There are a few validation techniques we could use, but none of them felt particularly clean. One option we could consider is an enum like this:Then for the non-Custom variants we could ensure the mode is set to octal, which then would only expose the footgun to users who opt in to a custom mode.
However this adds some bloat, and I appreciate the
logrolleris very lightweight, so we might just deem this footgun acceptable.