From ec0bbf4e76f8d8216cf4386bb2142acb17f9959e Mon Sep 17 00:00:00 2001 From: Csonka Mihaly Date: Sun, 22 Mar 2020 23:50:44 +0100 Subject: [PATCH] Fix remove dir panicing when the dir does not exist, but when the purpose is to make place for a replacement. --- src/flows/repo.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flows/repo.rs b/src/flows/repo.rs index 8c9a71d..dd89331 100644 --- a/src/flows/repo.rs +++ b/src/flows/repo.rs @@ -12,7 +12,10 @@ use walkdir::WalkDir; pub fn browse() -> Result<(), Error> { let repo_path_str = format!("{}/featured", filesystem::tmp_path_str()?); - filesystem::remove_dir(&repo_path_str)?; + // The dir might not exist which would throw an error. But here we don't care about that + // since our purpose is to make space for a new directory. Potential other errors + // (e.g due to lack of permission) will cause an error during dir creation. + let _ = filesystem::remove_dir(&repo_path_str); filesystem::create_dir(&repo_path_str)?; let repo_url = "https://github.com/denisidoro/cheats";