-
Notifications
You must be signed in to change notification settings - Fork 880
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
dist: Support a bincoded manifest file for performance reasons #2627
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,20 +52,24 @@ pub fn if_not_empty<S: PartialEq<str>>(s: S) -> Option<S> { | |
} | ||
} | ||
|
||
pub fn write_file(path: &Path, contents: &str) -> io::Result<()> { | ||
pub fn write_file_bytes(path: &Path, contents: &[u8]) -> io::Result<()> { | ||
let mut file = fs::OpenOptions::new() | ||
.write(true) | ||
.truncate(true) | ||
.create(true) | ||
.open(path)?; | ||
|
||
io::Write::write_all(&mut file, contents.as_bytes())?; | ||
io::Write::write_all(&mut file, contents)?; | ||
|
||
file.sync_data()?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn write_file(path: &Path, contents: &str) -> io::Result<()> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this pays for itself vs write_file(path, contents.as_bytes())?; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough, I'll sort out a refactor commit alongside this which pushes that up to the call sites. |
||
write_file_bytes(path, contents.as_bytes()) | ||
} | ||
|
||
pub fn filter_file<F: FnMut(&str) -> bool>( | ||
src: &Path, | ||
dest: &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.
I note this is doing a sync_data - this is an important part of the contract of the function; if we're renaming it perhaps consider exposing that at the same time - e.g. namespacing it or adding _synced or something.
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 agree with this idea and will sort it out