Improve config lookup and OpenAI streaming decode

This commit is contained in:
2025-10-01 17:27:37 +02:00
parent dccaf8e870
commit 4271ee3d73
5 changed files with 178 additions and 32 deletions

View File

@@ -87,20 +87,26 @@ func resolvePath(cfg config.StorageConfig) (string, error) {
return cfg.Path, nil
}
username := cfg.Username
if username == "" {
username = os.Getenv("USER")
if username == "" {
username = "default"
baseDir := strings.TrimSpace(cfg.BaseDir)
if baseDir == "" {
home, err := os.UserHomeDir()
if err == nil && strings.TrimSpace(home) != "" {
baseDir = filepath.Join(home, ".local", "share", "goaichat")
}
}
base := filepath.Join("/var/log/goaichat", username)
if cfg.BaseDir != "" {
base = cfg.BaseDir
if baseDir == "" {
username := strings.TrimSpace(cfg.Username)
if username == "" {
username = strings.TrimSpace(os.Getenv("USER"))
if username == "" {
username = "default"
}
}
baseDir = filepath.Join(os.TempDir(), "goaichat", username)
}
return filepath.Join(base, "goaichat.db"), nil
return filepath.Join(baseDir, "goaichat.db"), nil
}
func ensureDir(dir string) error {