diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-29 13:20:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-29 13:20:00 +0800 |
| commit | d193950d204ed82bdb3d6a3a111511d189f084bb (patch) | |
| tree | 5331dd37911dd991fc4c6060c7e5427bf4f850fa /src/utils/mod.rs | |
| parent | 9416cbd8b81c0029572db854257cfc25991a12cd (diff) | |
| download | aichat-d193950d204ed82bdb3d6a3a111511d189f084bb.tar.gz | |
refactor: the name of temp file (#670)
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index e36a54b..548c6f1 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -38,8 +38,8 @@ pub fn now() -> String { pub fn get_env_name(key: &str) -> String { format!( "{}_{}", - env!("CARGO_CRATE_NAME").to_ascii_uppercase(), - key.to_ascii_uppercase(), + env!("CARGO_CRATE_NAME").to_uppercase(), + key.to_uppercase(), ) } @@ -183,6 +183,14 @@ pub fn safe_join_path<T1: AsRef<Path>, T2: AsRef<Path>>( } } +pub fn temp_file(prefix: &str, suffix: &str) -> PathBuf { + env::temp_dir().join(format!( + "{}{prefix}{}{suffix}", + env!("CARGO_CRATE_NAME").to_lowercase(), + uuid::Uuid::new_v4() + )) +} + pub fn set_proxy( builder: reqwest::ClientBuilder, proxy: Option<&String>, |
