fix: generate windows resource directories using resource_relpath, closes #4087. (#4111)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
Aitor Miguel Blanco 2022-05-13 22:56:04 +10:00 committed by GitHub
parent 2b6c24dff9
commit 787ea09adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-bundler": patch
---
Fixes resource bundling on Windows when the resource path includes root or parent directory components.

View File

@ -14,6 +14,7 @@ use log::info;
use regex::Regex;
use serde::{Deserialize, Serialize};
use sha2::Digest;
use tauri_utils::resources::resource_relpath;
use std::{
collections::{BTreeMap, HashMap},
fs::{create_dir_all, read_to_string, remove_dir_all, rename, write, File},
@ -796,13 +797,10 @@ fn generate_resource_data(settings: &Settings) -> crate::Result<ResourceMap> {
};
// split the resource path directories
let components_count = src.components().count();
let directories = src
let target_path = resource_relpath(&src);
let components_count = target_path.components().count();
let directories = target_path
.components()
.filter(|component| {
let comp = component.as_os_str();
comp != "." && comp != ".."
})
.take(components_count - 1) // the last component is the file
.collect::<Vec<_>>();