refactor: migrate more state paths to ~/.codewhale with legacy fallback
- Spillover directory (truncate.rs): prefer ~/.codewhale/tool_outputs - Memory storage (capacity_memory.rs): prefer ~/.codewhale/memory - Runtime logs (runtime_log.rs): prefer ~/.codewhale/logs - Crash dumps (utils.rs): prefer ~/.codewhale/crashes - Automations (automation_manager.rs): prefer ~/.codewhale/automations - TUI settings (settings.rs): prefer ~/.codewhale/tui.toml All paths fall back to the legacy ~/.deepseek location when the canonical path doesn't exist, preserving compatibility for existing installs. Part of #2231.
This commit is contained in:
@@ -795,8 +795,15 @@ pub fn default_automations_dir() -> PathBuf {
|
||||
}
|
||||
}
|
||||
dirs::home_dir()
|
||||
.map(|home| home.join(".deepseek").join("automations"))
|
||||
.unwrap_or_else(|| PathBuf::from(".deepseek").join("automations"))
|
||||
.map(|home| {
|
||||
let primary = home.join(".codewhale").join("automations");
|
||||
if primary.exists() {
|
||||
primary
|
||||
} else {
|
||||
home.join(".deepseek").join("automations")
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| PathBuf::from(".codewhale").join("automations"))
|
||||
}
|
||||
|
||||
pub type SharedAutomationManager = Arc<Mutex<AutomationManager>>;
|
||||
|
||||
@@ -56,14 +56,21 @@ fn capacity_memory_dirs() -> Vec<PathBuf> {
|
||||
|
||||
let mut dirs = Vec::new();
|
||||
if let Some(home) = dirs::home_dir() {
|
||||
// Prefer .codewhale, fall back to .deepseek
|
||||
let primary = home.join(".codewhale").join("memory");
|
||||
if primary.exists() {
|
||||
dirs.push(primary);
|
||||
}
|
||||
dirs.push(home.join(".deepseek").join("memory"));
|
||||
}
|
||||
|
||||
let cwd = std::env::current_dir()
|
||||
.unwrap_or_else(|_| PathBuf::from("."))
|
||||
.join(".deepseek")
|
||||
.join("memory");
|
||||
dirs.push(cwd);
|
||||
.unwrap_or_else(|_| PathBuf::from("."));
|
||||
let primary_cwd = cwd.join(".codewhale").join("memory");
|
||||
if primary_cwd.exists() {
|
||||
dirs.push(primary_cwd);
|
||||
}
|
||||
dirs.push(cwd.join(".deepseek").join("memory"));
|
||||
|
||||
dirs.dedup();
|
||||
dirs
|
||||
|
||||
@@ -157,17 +157,24 @@ pub fn init() -> Result<TuiLogGuard> {
|
||||
}
|
||||
|
||||
fn log_directory() -> Option<PathBuf> {
|
||||
let resolve = |base: PathBuf| -> Option<PathBuf> {
|
||||
let primary = base.join(".codewhale").join("logs");
|
||||
if primary.exists() {
|
||||
return Some(primary);
|
||||
}
|
||||
Some(base.join(".deepseek").join("logs"))
|
||||
};
|
||||
if let Some(home) = std::env::var_os("HOME").map(PathBuf::from)
|
||||
&& !home.as_os_str().is_empty()
|
||||
{
|
||||
return Some(home.join(".deepseek").join("logs"));
|
||||
return resolve(home);
|
||||
}
|
||||
if let Some(userprofile) = std::env::var_os("USERPROFILE").map(PathBuf::from)
|
||||
&& !userprofile.as_os_str().is_empty()
|
||||
{
|
||||
return Some(userprofile.join(".deepseek").join("logs"));
|
||||
return resolve(userprofile);
|
||||
}
|
||||
dirs::home_dir().map(|h| h.join(".deepseek").join("logs"))
|
||||
dirs::home_dir().and_then(|h| resolve(h))
|
||||
}
|
||||
|
||||
fn log_file_name(date: &str, pid: u32) -> String {
|
||||
|
||||
@@ -109,6 +109,10 @@ impl TuiPrefs {
|
||||
|
||||
let home = dirs::home_dir()
|
||||
.context("Failed to resolve home directory: cannot determine tui.toml path.")?;
|
||||
let primary = home.join(".codewhale").join("tui.toml");
|
||||
if primary.exists() {
|
||||
return Ok(primary);
|
||||
}
|
||||
Ok(home.join(".deepseek").join("tui.toml"))
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,11 @@ pub fn spillover_root() -> Option<PathBuf> {
|
||||
return Some(root);
|
||||
}
|
||||
|
||||
// Prefer .codewhale, fall back to .deepseek
|
||||
let primary = dirs::home_dir()?.join(".codewhale").join(SPILLOVER_DIR_NAME);
|
||||
if primary.exists() {
|
||||
return Some(primary);
|
||||
}
|
||||
Some(dirs::home_dir()?.join(".deepseek").join(SPILLOVER_DIR_NAME))
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -259,7 +259,17 @@ fn write_panic_dump(
|
||||
let home = dirs::home_dir().ok_or_else(|| {
|
||||
std::io::Error::new(std::io::ErrorKind::NotFound, "home directory not found")
|
||||
})?;
|
||||
let crash_dir = home.join(".deepseek").join("crashes");
|
||||
// Prefer .codewhale, fall back to .deepseek
|
||||
let crash_dir = home.join(".codewhale").join("crashes");
|
||||
if !crash_dir.exists() {
|
||||
// Try legacy path for reading, but prefer new for writing
|
||||
let _ = std::fs::create_dir_all(&crash_dir);
|
||||
}
|
||||
let crash_dir = if crash_dir.exists() {
|
||||
crash_dir
|
||||
} else {
|
||||
home.join(".deepseek").join("crashes")
|
||||
};
|
||||
write_panic_dump_to(&crash_dir, name, location, message)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user