-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix(android): avoid rebuilds if nothing changed #10648
Conversation
Unconditionally overwriting files where the build reruns if they changed leads to rebuilds every time. Only overwrite a file if its content is different to not rebuild in such a case.
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.
nice catch! I did face this issue before but never had the time to actually dig into this, thank you!
Package Changes Through e0ce57bThere are 5 changes which include tauri with prerelease, tauri-build with prerelease, tauri-utils with prerelease, tauri-cli with prerelease, @tauri-apps/cli with prerelease Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
core/tauri-utils/src/io.rs
Outdated
|
||
/// Write to the given file if the content is different. | ||
pub fn write_if_changed(content: &str, path: &Path) -> std::io::Result<()> { | ||
if content != read_to_string(path).unwrap_or_default() { |
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 does a probably unexpected thing if content == ""
. In that case the file is not created if it doesn’t already exist (due to the or_default
).
I think the solution from tauri-apps/wry#1342 is better
if read_to_string(path).map_or(true, |c| c != content) {
// …
}
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.
right right, let's fix that
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.
oh actually we already had a function with this functionality, i've pushed a change to use that one instead
Unconditionally overwriting files where the build reruns if they changed leads to rebuilds every time.
Only overwrite a file if its content is different to not rebuild in such a case.