fix bug
This commit is contained in:
@@ -2,14 +2,11 @@ package store
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"opencatd-open/pkg/vertexai"
|
"opencatd-open/pkg/vertexai"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -27,15 +24,9 @@ func init() {
|
|||||||
Key: vertex_auth,
|
Key: vertex_auth,
|
||||||
ApiSecret: vertex_auth,
|
ApiSecret: vertex_auth,
|
||||||
}
|
}
|
||||||
if err := db.Table("keys").Where("name = ?", Vertex.ProjectID).Find(&key).Error; err != nil {
|
if err := db.Where("name = ?", Vertex.ProjectID).FirstOrCreate(&key).Error; err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
log.Fatalln(fmt.Errorf("import vertex_auth json error: %w", err))
|
||||||
if err := db.Create(&key).Error; err != nil {
|
return
|
||||||
log.Fatalln(fmt.Errorf("import vertex_auth json error: %w", err))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.Fatalln(fmt.Errorf("import vertex_auth json error: %w", err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LoadKeysCache()
|
LoadKeysCache()
|
||||||
|
|||||||
Reference in New Issue
Block a user