Fix remove dir panicing when the dir does not exist, but when the purpose is to make place for a replacement.

This commit is contained in:
Csonka Mihaly 2020-03-22 23:50:44 +01:00
parent 09dfc32d2c
commit ec0bbf4e76

View file

@ -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";