summaryrefslogtreecommitdiff
path: root/cli/util/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/util/fs.rs')
-rw-r--r--cli/util/fs.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/cli/util/fs.rs b/cli/util/fs.rs
index c1fd00f5e..33eb3af9d 100644
--- a/cli/util/fs.rs
+++ b/cli/util/fs.rs
@@ -206,8 +206,14 @@ pub fn canonicalize_path_maybe_not_exists_with_fs(
return Ok(canonicalized_path);
}
Err(err) if err.kind() == ErrorKind::NotFound => {
- names_stack.push(path.file_name().unwrap());
- path = path.parent().unwrap();
+ names_stack.push(match path.file_name() {
+ Some(name) => name.to_owned(),
+ None => return Err(err),
+ });
+ path = match path.parent() {
+ Some(parent) => parent,
+ None => return Err(err),
+ };
}
Err(err) => return Err(err),
}