Skip to content

Commit

Permalink
fix(build): avoid copying resource onto itself (tauri-apps#9710)
Browse files Browse the repository at this point in the history
* fix(build): avoid copying resource onto itself

closes tauri-apps#9666

* canonicalize once

---------

Co-authored-by: Lucas Nogueira <[email protected]>
  • Loading branch information
amrbashir and lucasfernog committed May 28, 2024
1 parent ccc3ea7 commit 19b696b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/build-resource-target-same-src.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-build": "patch:bug"
---

Avoid copying resources if the target path is the same as source.

10 changes: 9 additions & 1 deletion core/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,18 @@ fn copy_binaries(

/// Copies resources to a path.
fn copy_resources(resources: ResourcePaths<'_>, path: &Path) -> Result<()> {
let path = path.canonicalize()?;
for resource in resources.iter() {
let resource = resource?;

println!("cargo:rerun-if-changed={}", resource.path().display());
copy_file(resource.path(), path.join(resource.target()))?;

// avoid copying the resource if target is the same as source
let src = resource.path().canonicalize()?;
let target = path.join(resource.target());
if src != target {
copy_file(src, target)?;
}
}
Ok(())
}
Expand Down

0 comments on commit 19b696b

Please sign in to comment.