on master help sign in
show skip message when asset cache is not found
commitd5f737f402e9298ca49b1451e0e7868565666bfc authorrhysd <lin90162@yahoo.co.jp> dateMon 11 Oct 2021, 16:47 (5 years ago) parent7fe4fdf
1 file changed+11−2
src/bin/bat/assets.rs+11−2
src/bin/bat/assets.rs+11−2
@@ -1,5 +1,6 @@
11use std::borrow::Cow;
22use std::fs;
3+use std::io;
34
45use clap::crate_version;
56
@@ -52,6 +53,14 @@ pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<Highlighti
5253
5354fn clear_asset(filename: &str, description: &str) {
5455 print!("Clearing {} ... ", description);
55− fs::remove_file(PROJECT_DIRS.cache_dir().join(filename)).ok();
56− println!("okay");
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+ }
64+ Ok(_) => println!("okay"),
65+ }
5766}