1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 19:32:25 +01:00

Support a hidden arg --no-custom-assets that skips loading assets from the cache

This commit is contained in:
Martin Nordholts
2021-07-27 20:11:58 +02:00
parent a81009607a
commit b040efff79
7 changed files with 33 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ pub fn clear_assets() {
clear_asset("metadata.yaml", "metadata file");
}
pub fn assets_from_cache_or_binary() -> Result<HighlightingAssets> {
pub fn assets_from_cache_or_binary(use_custom_assets: bool) -> Result<HighlightingAssets> {
let cache_dir = PROJECT_DIRS.cache_dir();
if let Some(metadata) = AssetsMetadata::load_from_folder(&cache_dir)? {
if !metadata.is_compatible_with(crate_version!()) {
@@ -41,8 +41,12 @@ pub fn assets_from_cache_or_binary() -> Result<HighlightingAssets> {
}
}
Ok(HighlightingAssets::from_cache(&cache_dir)
.unwrap_or_else(|_| HighlightingAssets::from_binary()))
let custom_assets = if use_custom_assets {
HighlightingAssets::from_cache(&cache_dir).ok()
} else {
None
};
Ok(custom_assets.unwrap_or_else(HighlightingAssets::from_binary))
}
fn clear_asset(filename: &str, description: &str) {