Forráskód Böngészése

fix(core): canonicalize resource dir to fix scope check, closes #5196 (#5218)

Lucas Fernandes Nogueira 2 éve
szülő
commit
a06dc69931

+ 5 - 0
.changes/fix-resource-scope.md

@@ -0,0 +1,5 @@
+---
+"tauri": patch
+---
+
+Fixes resource reading being always rejected by the scope.

+ 5 - 0
.changes/resource-dir-canonicalize.md

@@ -0,0 +1,5 @@
+---
+"tauri-utils": patch
+---
+
+Canonicalize the return value of `platform::resource_dir`.

+ 8 - 2
core/tauri-utils/src/platform.rs

@@ -172,7 +172,10 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
   {
     res = if curr_dir.ends_with("/data/usr/bin") {
       // running from the deb bundle dir
-      Ok(exe_dir.join(format!("../lib/{}", package_info.package_name())))
+      exe_dir
+        .join(format!("../lib/{}", package_info.package_name()))
+        .canonicalize()
+        .map_err(Into::into)
     } else if let Some(appdir) = &env.appdir {
       let appdir: &std::path::Path = appdir.as_ref();
       Ok(PathBuf::from(format!(
@@ -191,7 +194,10 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
 
   #[cfg(target_os = "macos")]
   {
-    res = Ok(exe_dir.join("../Resources"));
+    res = exe_dir
+      .join("../Resources")
+      .canonicalize()
+      .map_err(Into::into);
   }
 
   res