diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-06-25 21:44:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 21:44:27 -0400 |
commit | 1f4cdc067a4e26921ee53d58751bb60279d3cab2 (patch) | |
tree | a361a4ad3956f80e062eb5cd9a69c41faca47d9d /cli/fs_util.rs | |
parent | 2f1ac460912f0faf3806e320b287573d1af762aa (diff) |
fix(lsp): reload import registries should not error when the module registries directory does not exist (#11123)
Diffstat (limited to 'cli/fs_util.rs')
-rw-r--r-- | cli/fs_util.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/fs_util.rs b/cli/fs_util.rs index a862e4bd3..462bbdddb 100644 --- a/cli/fs_util.rs +++ b/cli/fs_util.rs @@ -161,6 +161,16 @@ where Ok(target_files) } +// Asynchronously removes a directory and all its descendants, but does not error +// when the directory does not exist. +pub async fn remove_dir_all_if_exists(path: &Path) -> std::io::Result<()> { + let result = tokio::fs::remove_dir_all(path).await; + match result { + Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()), + _ => result, + } +} + #[cfg(test)] mod tests { use super::*; |