From d2c0d92fa2ab9807fecf72c5a088351bb155448c Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 2 Dec 2024 15:40:05 +0900 Subject: [PATCH] local_working_copy: propagate read_dir error from snapshot() --- lib/src/local_working_copy.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/local_working_copy.rs b/lib/src/local_working_copy.rs index 4ea5e1ced9..619aecc446 100644 --- a/lib/src/local_working_copy.rs +++ b/lib/src/local_working_copy.rs @@ -1043,11 +1043,13 @@ impl TreeState { let git_ignore = git_ignore .chain_with_file(&dir.to_internal_dir_string(), disk_dir.join(".gitignore"))?; - let dir_entries = disk_dir + let dir_entries: Vec<_> = disk_dir .read_dir() - .unwrap() - .map(|maybe_entry| maybe_entry.unwrap()) - .collect_vec(); + .and_then(|entries| entries.try_collect()) + .map_err(|err| SnapshotError::Other { + message: format!("Failed to read directory {}", disk_dir.display()), + err: err.into(), + })?; dir_entries.into_par_iter().try_for_each_with( ( tree_entries_tx.clone(),