Improve config lookup and OpenAI streaming decode
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user