tauri icon indicating copy to clipboard operation
tauri copied to clipboard

fix(tauri-utils): Use write_if_changed more

Open Flakebi opened this issue 8 months ago • 2 comments

Replace fs::write with write_if_changed in two places. This can prevent unnecessary rebuilds. (I didn’t encounter any, but this should be ok nonetheless.)

Flakebi avatar Jun 16 '25 22:06 Flakebi

Package Changes Through 706fb55f1865e4968fc5698f2400b8f894b52473

There are 8 changes which include tauri-bundler with minor, tauri-cli with minor, tauri-codegen with minor, tauri-utils with minor, @tauri-apps/cli with minor, tauri with minor, @tauri-apps/api with minor, tauri-runtime-wry with patch

Planned Package Versions

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

package current next
@tauri-apps/api 2.5.0 2.6.0
tauri-utils 2.4.0 2.5.0
tauri-bundler 2.4.0 2.5.0
tauri-runtime 2.6.0 2.6.1
tauri-runtime-wry 2.6.0 2.6.1
tauri-codegen 2.2.0 2.3.0
tauri-macros 2.2.0 2.2.1
tauri-plugin 2.2.0 2.2.1
tauri-build 2.2.0 2.2.1
tauri 2.5.1 2.6.0
@tauri-apps/cli 2.5.0 2.6.0
tauri-cli 2.5.0 2.6.0

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


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

github-actions[bot] avatar Jun 17 '25 01:06 github-actions[bot]

I believe these 2 places are used only in target (OUT_DIR) directory and we don't need to guard it here

Legend-Master avatar Jun 17 '25 01:06 Legend-Master

write_if_changed should be used when the generated file is a dependency for another build step or process (i.e. by include!ing the generated file). If the written file changes, cargo will trigger the dependent build step. If the file doesn’t change, cargo can skip the dependent step.

I agree with you that write_if_changed shouldn’t matter here if src is read-only or not. But for the benefit of unnecessary rebuilds, it shouldn’t really matter if the file is in OUT_DIR or somewhere else, write_if_changed can have benefits nonetheless. For what it’s worth, there are other places that use write_if_changed for files in OUT_DIR: https://github.com/tauri-apps/tauri/blob/100dc94c4847ee9a684f38f73d882dc5ac174941/crates/tauri-utils/src/acl/build.rs#L306

(Sorry for the slow response)

Flakebi avatar Oct 30 '25 09:10 Flakebi