Skip to content

Commit 19b696b

Browse files
fix(build): avoid copying resource onto itself (#9710)
* fix(build): avoid copying resource onto itself closes #9666 * canonicalize once --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent ccc3ea7 commit 19b696b

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-build": "patch:bug"
3+
---
4+
5+
Avoid copying resources if the target path is the same as source.
6+

core/tauri-build/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,18 @@ fn copy_binaries(
9393

9494
/// Copies resources to a path.
9595
fn copy_resources(resources: ResourcePaths<'_>, path: &Path) -> Result<()> {
96+
let path = path.canonicalize()?;
9697
for resource in resources.iter() {
9798
let resource = resource?;
99+
98100
println!("cargo:rerun-if-changed={}", resource.path().display());
99-
copy_file(resource.path(), path.join(resource.target()))?;
101+
102+
// avoid copying the resource if target is the same as source
103+
let src = resource.path().canonicalize()?;
104+
let target = path.join(resource.target());
105+
if src != target {
106+
copy_file(src, target)?;
107+
}
100108
}
101109
Ok(())
102110
}

0 commit comments

Comments
 (0)