From 42002eb57686d941864204caaef05ea5d7b24ecb Mon Sep 17 00:00:00 2001 From: Roland Schaer Date: Tue, 14 Jan 2025 15:58:11 -0300 Subject: [PATCH] fix: panic when directory name contains japanese characters --- src/backend/external_plugin_cache.rs | 2 +- src/config/config_file/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/external_plugin_cache.rs b/src/backend/external_plugin_cache.rs index 2b1a28e59c..0f0d328c59 100644 --- a/src/backend/external_plugin_cache.rs +++ b/src/backend/external_plugin_cache.rs @@ -84,7 +84,7 @@ fn render_cache_key(config: &Config, tv: &ToolVersion, cache_key: &[String]) -> let s = s.trim().to_string(); trace!("cache key element: {} -> {}", tmpl.trim(), s); let mut s = hash_to_str(&s); - s.truncate(10); + s = s.chars().take(10).collect(); s }) .collect::>(); diff --git a/src/config/config_file/mod.rs b/src/config/config_file/mod.rs index dfdf9c27b0..a60471b6f4 100644 --- a/src/config/config_file/mod.rs +++ b/src/config/config_file/mod.rs @@ -467,7 +467,7 @@ fn hashed_path_filename(path: &Path) -> String { let hash = hash_to_str(&canonicalized_path); let trunc_str = |s: &OsStr| { let mut s = s.to_str().unwrap().to_string(); - s.truncate(20); + s = s.chars().take(20).collect(); s }; let trust_path = dirs::TRUSTED_CONFIGS.join(hash_to_str(&hash));