mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
Ensure auth directory existence before processing tokens in run.go
This commit is contained in:
@@ -51,6 +51,20 @@ func StartService(cfg *config.Config, configPath string) {
|
|||||||
// Create a pool of API clients, one for each token file found.
|
// Create a pool of API clients, one for each token file found.
|
||||||
cliClients := make(map[string]interfaces.Client)
|
cliClients := make(map[string]interfaces.Client)
|
||||||
successfulAuthCount := 0
|
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 {
|
err := filepath.Walk(cfg.AuthDir, func(path string, info fs.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user