Skip to content

fix: resource path handles ./ path differently#14662

Open
Legend-Master wants to merge 17 commits intotauri-apps:devfrom
Legend-Master:refactor-resource-path-iter
Open

fix: resource path handles ./ path differently#14662
Legend-Master wants to merge 17 commits intotauri-apps:devfrom
Legend-Master:refactor-resource-path-iter

Conversation

@Legend-Master
Copy link
Contributor

@Legend-Master Legend-Master commented Dec 16, 2025

Fix #14659

Also added CI for tauri-utils

@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Dec 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Package Changes Through 628d6ba

There are 9 changes which include tauri-utils with patch, tauri-build with patch, tauri-cli with minor, tauri-macos-sign with patch, @tauri-apps/cli with minor, tauri with minor, tauri-bundler with minor, tauri-runtime-wry with minor, tauri-runtime with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.8.1 2.8.2
tauri-macos-sign 2.3.2 2.3.3
tauri-bundler 2.7.5 2.8.0
tauri-runtime 2.9.2 2.10.0
tauri-runtime-wry 2.9.3 2.10.0
tauri-codegen 2.5.2 2.5.3
tauri-macros 2.5.2 2.5.3
tauri-plugin 2.5.2 2.5.3
tauri-build 2.5.3 2.5.4
tauri 2.9.5 2.10.0
@tauri-apps/cli 2.9.6 2.10.0
tauri-cli 2.9.6 2.10.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Comment on lines +241 to +256
let path = normalize(Path::new(pattern));
if path.is_dir() {
if !self.allow_walk {
return Some(Err(crate::Error::NotAllowedToWalkDir(path)));
}
self.current_iter = Some(ResourcePathsInnerIter::Walk {
iter: WalkDir::new(&path).into_iter(),
current_pattern: if matches!(self.pattern_iter, PatternIter::Map(_)) {
Some(path)
} else {
None
},
});
} else {
return Some(self.resource_from_path(path));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replaced next_current_path

Comment on lines 134 to 180
current_iter: Option<ResourcePathsInnerIter>,
}

impl ResourcePathsIter<'_> {
fn next_glob_iter(&mut self) -> Option<crate::Result<Resource>> {
let entry = self.glob_iter.as_mut().unwrap().next()?;
#[derive(Debug)]
enum ResourcePathsInnerIter {
Walk {
iter: walkdir::IntoIter,
current_pattern: Option<PathBuf>,
},
Glob {
iter: glob::Paths,
},
}

let entry = match entry {
Ok(entry) => entry,
Err(err) => return Some(Err(err.into())),
};
impl Iterator for ResourcePathsInnerIter {
type Item = crate::Result<PathBuf>;

self.next_current_path(normalize(&entry))
fn next(&mut self) -> Option<crate::Result<PathBuf>> {
match self {
ResourcePathsInnerIter::Walk { iter, .. } => Some(
iter
.next()?
.map(|entry| entry.into_path())
.map_err(Into::into),
),
ResourcePathsInnerIter::Glob { iter } => Some(iter.next()?.map_err(Into::into)),
}
}
}

fn next_walk_iter(&mut self) -> Option<crate::Result<Resource>> {
let entry = self.walk_iter.as_mut().unwrap().next()?;

let entry = match entry {
Ok(entry) => entry,
Err(err) => return Some(Err(err.into())),
};

self.next_current_path(normalize(entry.path()))
impl ResourcePathsIter<'_> {
fn next_current_iter(&mut self) -> Option<crate::Result<Resource>> {
let current_iter = self.current_iter.as_mut().unwrap();
let entry = current_iter.next()?;

Some(match entry {
Ok(entry) => {
// Skip directories
if entry.is_dir() {
self.next_current_iter()?
} else {
self.resource_from_path(normalize(&entry))
}
}
Err(error) => Err(error),
})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grouped walk iter and glob iter into a enum since they're mutually exclusive

(
"../src/textures/ground/earth.tex",
"_up_/src/textures/earth.tex",
"_up_/src/textures/ground/earth.tex",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't run those tests before and they were failing from the very beginning...

// if processing a directory, preserve directory structure under current_dest
if self.walk_iter.is_some() {
dest.join(path.strip_prefix(pattern).unwrap_or(path))
} else if dest.components().count() == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this possible? We have normalized this path and join for an empty PathBuf (PathBuf::from("")) should be the same as what's joined to anyways

@Legend-Master Legend-Master marked this pull request as ready for review December 16, 2025 06:45
@Legend-Master Legend-Master requested a review from a team as a code owner December 16, 2025 06:45
@FabianLars FabianLars mentioned this pull request Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

[bug] Follow-up: cargo test still fails on Windows [bug] resources path mapping issue

3 participants