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>
This commit is contained in:
Amr Bashir 2024-05-28 19:48:52 +03:00 committed by GitHub
parent ccc3ea729d
commit 19b696b61c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-build": "patch:bug"
---
Avoid copying resources if the target path is the same as source.

View File

@ -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(())
}