Compare commits

..

2 Commits

2 changed files with 16 additions and 2 deletions

View File

@@ -51,6 +51,20 @@ func StartService(cfg *config.Config, configPath string) {
// Create a pool of API clients, one for each token file found.
cliClients := make(map[string]interfaces.Client)
successfulAuthCount := 0
// Ensure the auth directory exists before walking it.
if info, statErr := os.Stat(cfg.AuthDir); statErr != nil {
if os.IsNotExist(statErr) {
if mkErr := os.MkdirAll(cfg.AuthDir, 0755); mkErr != nil {
log.Fatalf("failed to create auth directory %s: %v", cfg.AuthDir, mkErr)
}
log.Infof("created missing auth directory: %s", cfg.AuthDir)
} else {
log.Fatalf("error checking auth directory %s: %v", cfg.AuthDir, statErr)
}
} else if !info.IsDir() {
log.Fatalf("auth path exists but is not a directory: %s", cfg.AuthDir)
}
err := filepath.Walk(cfg.AuthDir, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
@@ -65,7 +79,7 @@ func StartService(cfg *config.Config, configPath string) {
}
// Determine token type from JSON data, defaulting to "gemini" if not specified.
tokenType := "gemini"
tokenType := ""
typeResult := gjson.GetBytes(data, "type")
if typeResult.Exists() {
tokenType = typeResult.String()

View File

@@ -335,7 +335,7 @@ func (w *Watcher) createClientFromFile(path string, cfg *config.Config) (interfa
return nil, nil // Not an error, just nothing to process yet.
}
tokenType := "gemini"
tokenType := ""
typeResult := gjson.GetBytes(data, "type")
if typeResult.Exists() {
tokenType = typeResult.String()