Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changes/resources-after-empty-diretory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"tauri-utils": "patch:bug"
---

Fix a regression in tauri-utils 2.8.3 that made an empty directory makes it skip all the following entries, e.g.

```json
{
"bundle": {
"resources": [
"empty-directory",
"README.md"
]
}
}
```

if `empty-directory` is empty, the `README.md` will not be copied to the resource directory (skipped)
14 changes: 9 additions & 5 deletions crates/tauri-utils/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl ResourcePathsIter<'_> {

fn next_pattern(&mut self) -> Option<crate::Result<Resource>> {
self.current_dest = None;
self.current_iter = None;

let pattern = match &mut self.pattern_iter {
PatternIter::Slice(iter) => iter.next()?,
Expand All @@ -237,10 +238,10 @@ impl ResourcePathsIter<'_> {
Err(error) => return Some(Err(error.into())),
};
match self.next_current_iter() {
Some(r) => return Some(r),
Some(r) => Some(r),
None => {
self.current_iter = None;
return Some(Err(crate::Error::GlobPathNotFound(pattern.clone())));
Some(Err(crate::Error::GlobPathNotFound(pattern.clone())))
}
}
} else {
Expand All @@ -257,12 +258,12 @@ impl ResourcePathsIter<'_> {
None
},
});
// If the directory is empty, skip and continue to the next pattern
self.next_current_iter().or_else(|| self.next_pattern())
} else {
return Some(self.resource_from_path(path));
Some(self.resource_from_path(path))
}
}

self.next_current_iter()
}
}

Expand Down Expand Up @@ -358,6 +359,7 @@ mod tests {
fs::create_dir_all(path.parent().unwrap()).unwrap();
fs::write(path, "").unwrap();
}
fs::create_dir_all("empty-directory").unwrap();
}

fn resources_map(literal: &[(&str, &str)]) -> HashMap<String, String> {
Expand All @@ -377,6 +379,8 @@ mod tests {

let resources = ResourcePaths::new(
&[
// `empty-directory` should not affect anything
"../empty-directory".into(),
"../src/script.js".into(),
"../src/assets".into(),
"../src/index.html".into(),
Expand Down
Loading