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

This commit is contained in:
Lucas Fernandes Nogueira 2022-09-29 16:33:48 -03:00 committed by GitHub
parent ca3cd8b3d1
commit a06dc69931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

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

View File

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

View File

@ -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