Skip to content

Commit 9e89193

Browse files
fix(utils): fix resources map becomes directory (#10293)
* fix(utils): fix resources map becomes directory closes #10187 Fixes the behavior of mapped resources generating extra directory, for example: `"../resources/user.json": "resources/user.json"` generates this resource `resources/user.json/user.json` where it should generate `resources/user.json` This PR includes a refactor of the Iterator implementation which splits it into more scoped functions and relis on recursing instead of a loop which makes the code a lot more readable and easier to maintain. * clippy * cover more cases * clippy * fix glob into directory, not resolving target correctly * return error when resource origin path doesn't exist * fix resources example build * Update .changes/resources-map-becoming-dirs.md --------- Co-authored-by: Lucas Nogueira <[email protected]>
1 parent 8deb196 commit 9e89193

File tree

6 files changed

+505
-130
lines changed

6 files changed

+505
-130
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": "patch:bug"
3+
---
4+
5+
Fix `ResourcePaths` iterator returning an unexpected result for mapped resources, for example `"../resources/user.json": "resources/user.json"` generates this resource `resources/user.json/user.json` where it should generate just `resources/user.json`.

Cargo.lock

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tauri-utils/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ serde-untagged = "0.1"
4747
[target."cfg(target_os = \"macos\")".dependencies]
4848
swift-rs = { version = "1.0.6", optional = true, features = [ "build" ] }
4949

50+
[dev-dependencies]
51+
getrandom = { version = "0.2", features = [ "std" ] }
52+
serial_test = "3.1"
53+
5054
[features]
5155
build = [
5256
"proc-macro2",

core/tauri-utils/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ pub enum Error {
372372
#[cfg(feature = "resources")]
373373
#[error("could not walk directory `{0}`, try changing `allow_walk` to true on the `ResourcePaths` constructor.")]
374374
NotAllowedToWalkDir(std::path::PathBuf),
375+
/// Resourece path doesn't exist
376+
#[cfg(feature = "resources")]
377+
#[error("resource path `{0}` doesn't exist")]
378+
ResourcePathNotFound(std::path::PathBuf),
375379
}
376380

377381
/// Reconstructs a path from its components using the platform separator then converts it to String and removes UNC prefixes on Windows if it exists.

0 commit comments

Comments
 (0)