on master help sign in
show skip message when asset cache is not found
d5f737frhysd
src/bin/bat/assets.rs+11−2
@@ -1,5 +1,6 @@
1use std::borrow::Cow;
1use std::borrow::Cow;
2use std::fs;
2use std::fs;
3+use std::io;
3
4
4use clap::crate_version;
5use clap::crate_version;
5
6
@@ -52,6 +53,14 @@ pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<Highlighti
52
53
53fn clear_asset(filename: &str, description: &str) {
54fn clear_asset(filename: &str, description: &str) {
54 print!("Clearing {} ... ", description);
55 print!("Clearing {} ... ", description);
55− fs::remove_file(PROJECT_DIRS.cache_dir().join(filename)).ok();
56+ let path = PROJECT_DIRS.cache_dir().join(filename);
57+ match fs::remove_file(&path) {
58+ Err(err) if err.kind() == io::ErrorKind::NotFound => {
59+ println!("skipped (not present)");
60+ }
61+ Err(err) => {
62+ println!("could not remove the cache file {:?}: {}", &path, err);
63+ }
56− println!("okay");
64+ Ok(_) => println!("okay"),
65+ }
57}
66}