summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrhysd <lin90162@yahoo.co.jp>2021-10-11 16:47:48 +0900
committerDavid Peter <sharkdp@users.noreply.github.com>2021-10-26 21:34:10 +0200
commitd5f737f402e9298ca49b1451e0e7868565666bfc (patch)
tree1605078f8e9a07b324869b4b71f75247f4836b9b
parent7fe4fdf33df3aa958b3263a939a8b24b9d06f534 (diff)
show skip message when asset cache is not found
-rw-r--r--src/bin/bat/assets.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/bin/bat/assets.rs b/src/bin/bat/assets.rs
index b775a4d9..26d599b2 100644
--- a/src/bin/bat/assets.rs
+++ b/src/bin/bat/assets.rs
@@ -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"),
+ }
}