Skip to content
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

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

Flakebi
Copy link
Contributor

@Flakebi Flakebi commented Aug 16, 2024

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.

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.
@Flakebi Flakebi requested a review from a team as a code owner August 16, 2024 09:11
lucasfernog
lucasfernog previously approved these changes Aug 19, 2024
Copy link
Member

@lucasfernog lucasfernog left a 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!

Copy link
Contributor

github-actions bot commented Aug 19, 2024

Package Changes Through e0ce57b

There 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 Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.0.0-rc.3 2.0.0-rc.4
tauri-bundler 2.0.1-rc.2 2.0.1-rc.3
tauri-runtime 2.0.0-rc.3 2.0.0-rc.4
tauri-runtime-wry 2.0.0-rc.3 2.0.0-rc.4
tauri-codegen 2.0.0-rc.3 2.0.0-rc.4
tauri-macros 2.0.0-rc.3 2.0.0-rc.4
tauri-plugin 2.0.0-rc.3 2.0.0-rc.4
tauri-build 2.0.0-rc.3 2.0.0-rc.4
tauri 2.0.0-rc.3 2.0.0-rc.4
@tauri-apps/cli 2.0.0-rc.4 2.0.0-rc.5
tauri-cli 2.0.0-rc.4 2.0.0-rc.5

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector


/// 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() {
Copy link
Contributor Author

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) {
  // …
}

Copy link
Member

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

Copy link
Member

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

@lucasfernog lucasfernog merged commit 5c335ae into tauri-apps:dev Aug 19, 2024
26 of 27 checks passed
@Flakebi Flakebi deleted the rebuild branch August 19, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants