fix(android): avoid rebuilds if nothing changed#10648
fix(android): avoid rebuilds if nothing changed#10648lucasfernog merged 3 commits intotauri-apps:devfrom
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.
lucasfernog
left a comment
There was a problem hiding this comment.
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.
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.
right right, let's fix that
There was a problem hiding this comment.
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.