Skip to content

Commit be27778

Browse files
committed
Avoid panic in profile directory walk
Replace an internal expect() in the installer walkdir path handling with a structured IO error to keep failure behavior recoverable.
1 parent f82bbd0 commit be27778

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/profiles/installer.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,13 @@ fn copy_directory_contents(
293293
for entry in WalkDir::new(source_dir).follow_links(true) {
294294
let entry = entry.map_err(|e| ProfileError::IoError(std::io::Error::other(e)))?;
295295
let entry_path = entry.path();
296-
let relative = entry_path
297-
.strip_prefix(source_dir)
298-
.expect("walkdir entry should be under source_dir");
296+
let relative = entry_path.strip_prefix(source_dir).map_err(|_| {
297+
ProfileError::IoError(std::io::Error::other(format!(
298+
"walkdir entry '{}' is outside source '{}'",
299+
entry_path.display(),
300+
source_dir.display()
301+
)))
302+
})?;
299303

300304
if relative.as_os_str().is_empty() {
301305
continue;

0 commit comments

Comments
 (0)