Skip to content

Commit b5b72ce

Browse files
fix(tauri-utils): preserve resource source file name when dest is empty (#15383)
1 parent 3fd8ba2 commit b5b72ce

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"tauri-utils": "patch:bug"
3+
---
4+
5+
Fix a regression in tauri-utils 2.8.3 that made empty path an invalid resource target, e.g.
6+
7+
```json
8+
{
9+
"bundle": {
10+
"resources": {
11+
"README.md": "",
12+
}
13+
}
14+
}
15+
```
16+
17+
(this means `README.md` -> `$RESOURCE/README.md`, note this is a confusing behavior, and will be changed in v3)

crates/tauri-utils/src/resources.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,21 @@ impl ResourcePathsIter<'_> {
209209
// preserving the file name as it is
210210
ResourcePathsInnerIter::Glob { .. } => dest.join(path.file_name().unwrap()),
211211
},
212-
None => dest.clone(),
212+
None => {
213+
if dest.components().count() == 0 {
214+
// if current_dest is empty while processing a file pattern
215+
// we preserve the file name as it is
216+
//
217+
// e.g. `{ "README.md": "" }` is `README.md` -> `$RESOURCE/README.md`
218+
//
219+
// TODO: This behavior is a confusing special case,
220+
// remove this in v3 or make other cases like this work
221+
// > `{ "README.md": "./folder/" }` is `README.md` -> `$RESOURCE/folder/README.md` (this gives `$RESOURCE/folder` today)
222+
PathBuf::from(path.file_name().unwrap())
223+
} else {
224+
dest.clone()
225+
}
226+
}
213227
}
214228
} else {
215229
// If [`ResourcePathsIter::pattern_iter`] is a [`PatternIter::Slice`]

0 commit comments

Comments
 (0)