From ca82dfa9d2c8b96191237e562e7110eba2f703c1 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 10 Apr 2023 08:36:53 +0200 Subject: [PATCH] Merge pull request #2366 from zed-industries/avoid-unwrapping-on-try-send Don't panic if worktree was dropped before sending path changes --- crates/project/src/worktree.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 2357052d2cb13ad819caa5eecce4f2f210675ea3..7bf3653164814486bdf40f3e631b3df67f527dad 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -841,8 +841,7 @@ impl LocalWorktree { .unwrap() .path_changes_tx .try_send((vec![abs_path], tx)) - .unwrap(); - }); + })?; rx.recv().await; Ok(()) })) @@ -933,7 +932,7 @@ impl LocalWorktree { } let (tx, mut rx) = barrier::channel(); - path_changes_tx.try_send((paths, tx)).unwrap(); + path_changes_tx.try_send((paths, tx))?; rx.recv().await; this.upgrade(&cx) .ok_or_else(|| anyhow!("worktree was dropped"))?