show skip message when asset cache is not found

This commit is contained in:
rhysd 2021-10-11 16:47:48 +09:00 committed by David Peter
parent 7fe4fdf33d
commit d5f737f402

View File

@ -1,5 +1,6 @@
use std::borrow::Cow;
use std::fs;
use std::io;
use clap::crate_version;
@ -52,6 +53,14 @@ pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<Highlighti
fn clear_asset(filename: &str, description: &str) {
print!("Clearing {} ... ", description);
fs::remove_file(PROJECT_DIRS.cache_dir().join(filename)).ok();
println!("okay");
let path = PROJECT_DIRS.cache_dir().join(filename);
match fs::remove_file(&path) {
Err(err) if err.kind() == io::ErrorKind::NotFound => {
println!("skipped (not present)");
}
Err(err) => {
println!("could not remove the cache file {:?}: {}", &path, err);
}
Ok(_) => println!("okay"),
}
}