-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a0b3d2
commit 403f950
Showing
10 changed files
with
78 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
use std::path::PathBuf; | ||
use std::{env, path::PathBuf}; | ||
|
||
use tauri::{api::path::app_cache_dir, Config}; | ||
|
||
pub fn cache_file_path(slug: &str) -> PathBuf { | ||
let cache_dir = app_cache_dir(&Config::default()).expect("load huggingface/hub cache dir"); | ||
let cache_dir = match env::var_os("USER") { | ||
Some(value) => { | ||
|
||
if cfg!(target_os = "macos") { | ||
PathBuf::from(format!("/Users/{}/.cache", value.to_string_lossy())) | ||
} else if cfg!(target_os = "linux") { | ||
PathBuf::from(format!("/home/{}/.cache", value.to_string_lossy())) | ||
} else { | ||
println!("\n\tUnspported OS!!!\n"); | ||
PathBuf::from(format!("/home/{}/.cache", value.to_string_lossy())) | ||
} | ||
}, | ||
None => app_cache_dir(&Config::default()).expect("load huggingface/hub cache dir"), | ||
}; | ||
|
||
let path = format!("huggingface/hub/{}", slug); | ||
|
||
cache_dir.join(path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
use std::path::PathBuf; | ||
use std::{env, path::PathBuf}; | ||
|
||
use tauri::{api::path::app_config_dir, Config}; | ||
|
||
pub fn config_file_path(slug: &str) -> PathBuf { | ||
let config_dir = app_config_dir(&Config::default()).expect("load tauri config"); | ||
let config_dir = app_config_file_path(); | ||
let fireside = "fireside-chat".to_string(); | ||
let config_dir_path = config_dir.join(fireside); | ||
_ = std::fs::create_dir_all(&config_dir_path); | ||
config_dir_path.join(slug) | ||
} | ||
|
||
pub fn config_file_dir() -> PathBuf { | ||
let config_dir = app_config_dir(&Config::default()).expect("load tauri config"); | ||
let config_dir = app_config_file_path(); | ||
let fireside = "fireside-chat".to_string(); | ||
let path = config_dir.join(fireside); | ||
_ = std::fs::create_dir_all(&path); | ||
path | ||
} | ||
|
||
pub fn context_file_dir() -> PathBuf { | ||
let config_dir = app_config_dir(&Config::default()).expect("load tauri config"); | ||
let config_dir = app_config_file_path(); | ||
let path = "fireside-chat/context".to_string(); | ||
let path = config_dir.join(path); | ||
_ = std::fs::create_dir_all(&path); | ||
path | ||
} | ||
|
||
|
||
pub fn app_config_file_path() -> PathBuf { | ||
match env::var_os("USER") { | ||
Some(value) => { | ||
|
||
if cfg!(target_os = "macos") { | ||
PathBuf::from(format!("/Users/{}/.config", value.to_string_lossy())) | ||
} else if cfg!(target_os = "linux") { | ||
PathBuf::from(format!("/home/{}/.config", value.to_string_lossy())) | ||
} else { | ||
println!("\n\tUnspported OS!!!\n"); | ||
app_config_dir(&Config::default()).expect("load huggingface/hub cache dir") | ||
} | ||
}, | ||
None => app_config_dir(&Config::default()).expect("load huggingface/hub cache dir"), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters