Skip to content

fix: resource path handles ./ path differently - #14662

Merged
Legend-Master merged 18 commits into
tauri-apps:devfrom
Legend-Master:refactor-resource-path-iter
Mar 3, 2026
Merged

fix: resource path handles ./ path differently#14662
Legend-Master merged 18 commits into
tauri-apps:devfrom
Legend-Master:refactor-resource-path-iter

Conversation

@Legend-Master

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

Copy link
Copy Markdown
Contributor

Fix #14659

Also added CI for tauri-utils

@github-actions

github-actions Bot commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Package Changes Through 47ff324

There are 4 changes which include tauri-cli with patch, @tauri-apps/cli with patch, tauri-utils with patch, tauri-bundler with patch

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.2 2.8.3
tauri-bundler 2.8.0 2.8.1
tauri-runtime 2.10.0 2.10.1
tauri-runtime-wry 2.10.0 2.10.1
tauri-codegen 2.5.4 2.5.5
tauri-macros 2.5.4 2.5.5
tauri-plugin 2.5.3 2.5.4
tauri-build 2.5.5 2.5.6
tauri 2.10.2 2.10.3
@tauri-apps/cli 2.10.0 2.10.1
tauri-cli 2.10.0 2.10.1

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread .github/workflows/test-utils.yml Outdated
Comment thread crates/tauri-utils/src/resources.rs Outdated
@FabianLars FabianLars mentioned this pull request Jan 1, 2026
@Legend-Master
Legend-Master merged commit c3cbff3 into tauri-apps:dev Mar 3, 2026
21 of 23 checks passed
@Legend-Master
Legend-Master deleted the refactor-resource-path-iter branch March 3, 2026 13:16
@sftse

sftse commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Is it fine that CI wasn't green? Looks like the tests in platform.rs should have been deactivated for android?

@Legend-Master

Copy link
Copy Markdown
Contributor Author

No, missed it completely since we got too many false alarms on the cache fail 🤦‍♂️

razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
* fix: resource path handles `./` path differently

* Setup CI for tauri utils

* Wrong job name

* Fix tests

* Always run tests and don't run doc tests

* Add change file

* Re-use `test-core` workflow

* Format

* Avoid path clone by calculating target first

* Test tauri-utils first with step instead of matrix

* Use `matrix.platform.command`

* Document `current_dest` and `current_pattern`

* More docs

* Merge remote-tracking branch 'upstream/dev' into refactor-resource-path-iter

* Test with doc tests

* Revert "Test with doc tests"

This reverts commit 388bee9.

* Merge branch 'dev' into refactor-resource-path-iter

* Merge branch 'dev' into refactor-resource-path-iter
razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
* fix: resource path handles `./` path differently

* Setup CI for tauri utils

* Wrong job name

* Fix tests

* Always run tests and don't run doc tests

* Add change file

* Re-use `test-core` workflow

* Format

* Avoid path clone by calculating target first

* Test tauri-utils first with step instead of matrix

* Use `matrix.platform.command`

* Document `current_dest` and `current_pattern`

* More docs

* Merge remote-tracking branch 'upstream/dev' into refactor-resource-path-iter

* Test with doc tests

* Revert "Test with doc tests"

This reverts commit 388bee9.

* Merge branch 'dev' into refactor-resource-path-iter

* Merge branch 'dev' into refactor-resource-path-iter
razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
* fix: resource path handles `./` path differently

* Setup CI for tauri utils

* Wrong job name

* Fix tests

* Always run tests and don't run doc tests

* Add change file

* Re-use `test-core` workflow

* Format

* Avoid path clone by calculating target first

* Test tauri-utils first with step instead of matrix

* Use `matrix.platform.command`

* Document `current_dest` and `current_pattern`

* More docs

* Merge remote-tracking branch 'upstream/dev' into refactor-resource-path-iter

* Test with doc tests

* Revert "Test with doc tests"

This reverts commit 388bee9.

* Merge branch 'dev' into refactor-resource-path-iter

* Merge branch 'dev' into refactor-resource-path-iter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

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