Skip to content

Commit 87a37ce

Browse files
committed
Avoid unnecessary unwrapping
1 parent f30518b commit 87a37ce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/dist/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -742,12 +742,12 @@ pub(crate) async fn update_from_dist(
742742
opts: &DistOptions<'_>,
743743
) -> Result<Option<String>> {
744744
let fresh_install = !prefix.path().exists();
745-
let hash_exists = opts.update_hash.map(Path::exists).unwrap_or(false);
746-
// fresh_install means the toolchain isn't present, but hash_exists means there is a stray hash file
747-
if fresh_install && hash_exists {
748-
// It's ok to unwrap, because hash have to exist at this point
749-
(opts.dl_cfg.notify_handler)(Notification::StrayHash(opts.update_hash.unwrap()));
750-
std::fs::remove_file(opts.update_hash.unwrap())?;
745+
if let Some(hash) = opts.update_hash {
746+
// fresh_install means the toolchain isn't present, but hash_exists means there is a stray hash file
747+
if fresh_install && Path::exists(hash) {
748+
(opts.dl_cfg.notify_handler)(Notification::StrayHash(hash));
749+
std::fs::remove_file(hash)?;
750+
}
751751
}
752752

753753
let res = update_from_dist_(

0 commit comments

Comments
 (0)