diff options
| author | sigoden <sigoden@gmail.com> | 2024-07-09 21:22:51 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-09 21:22:51 +0800 |
| commit | a9268b600fb378400795fbaf98bf923372b4c19a (patch) | |
| tree | ea0f3d79da0ae02041ad1313e9764a4750e8a3f1 /src/config/session.rs | |
| parent | 138c90b58bf90be84de3fedbbdf8e05bf0820a11 (diff) | |
| download | aichat-a9268b600fb378400795fbaf98bf923372b4c19a.tar.gz | |
feat: support agent variables (#692)
Diffstat (limited to 'src/config/session.rs')
| -rw-r--r-- | src/config/session.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/config/session.rs b/src/config/session.rs index 80629c1..792b22d 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -9,7 +9,7 @@ use inquire::{validator::Validation, Confirm, Text}; use serde::{Deserialize, Serialize}; use serde_json::json; use std::collections::HashMap; -use std::fs::{self, create_dir_all, read_to_string}; +use std::fs::{self, read_to_string}; use std::path::Path; #[derive(Debug, Clone, Default, Deserialize, Serialize)] @@ -314,13 +314,7 @@ impl Session { } pub fn save(&mut self, session_path: &Path, is_repl: bool) -> Result<()> { - if let Some(sessions_dir) = session_path.parent() { - if !sessions_dir.exists() { - create_dir_all(sessions_dir).with_context(|| { - format!("Failed to create session_dir '{}'", sessions_dir.display()) - })?; - } - } + ensure_parent_exists(session_path)?; self.path = Some(session_path.display().to_string()); |
