fix: resource path handles ./ path differently#14662
fix: resource path handles ./ path differently#14662Legend-Master wants to merge 17 commits intotauri-apps:devfrom
./ path differently#14662Conversation
Package Changes Through 628d6baThere 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 VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
| 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)); | ||
| } |
There was a problem hiding this comment.
This replaced next_current_path
| 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), | ||
| }) | ||
| } |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
Fix #14659
Also added CI for
tauri-utils