Skip to content

Commit d6fdf01

Browse files
committed
Fix home folder for metal
1 parent c7402f6 commit d6fdf01

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

mistralrs-core/src/pipeline/macros.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,21 @@ macro_rules! api_dir_list {
2626
.display()
2727
.to_string()
2828
.replace("/", "-");
29+
30+
let home_folder = if dirs::home_dir().is_some() {
31+
let mut path = dirs::home_dir().unwrap();
32+
path.push(".cache/huggingface/hub/");
33+
if !path.exists() {
34+
let _ = std::fs::create_dir_all(&path);
35+
}
36+
path
37+
} else {
38+
"./".into()
39+
};
40+
2941
let cache_dir: std::path::PathBuf = std::env::var("HF_HUB_CACHE")
3042
.map(std::path::PathBuf::from)
31-
.unwrap_or("~/.cache/huggingface/hub/".into());
43+
.unwrap_or(home_folder.into());
3244
let cache_file = cache_dir.join(format!("{sanitized_id}_repo_list.json"));
3345
if std::path::Path::new(&cache_file).exists() {
3446
use std::io::Read;
@@ -55,8 +67,8 @@ macro_rules! api_dir_list {
5567
};
5668
let json = serde_json::to_string_pretty(&cache)
5769
.expect("Could not serialize cache");
58-
let _ = std::fs::write(&cache_file, json);
59-
tracing::info!("write to cache file {:?}", cache_file);
70+
let ret = std::fs::write(&cache_file, json);
71+
tracing::info!("write to cache file {:?}, {:?}", cache_file, ret);
6072
files
6173
})
6274
.unwrap_or_else(|e| {

0 commit comments

Comments
 (0)