Quellcode durchsuchen

fix: maybe fail to sync config to remote node #775

Jacky vor 4 Monaten
Ursprung
Commit
3fecf9eb20
1 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  1. 4 1
      api/config/modify.go

+ 4 - 1
api/config/modify.go

@@ -10,6 +10,7 @@ import (
 	"github.com/gin-gonic/gin"
 	"github.com/sashabaranov/go-openai"
 	"github.com/uozi-tech/cosy"
+	"gorm.io/gen/field"
 	"net/http"
 	"os"
 	"path/filepath"
@@ -55,7 +56,9 @@ func EditConfig(c *gin.Context) {
 	}
 
 	q := query.Config
-	cfg, err := q.Where(q.Filepath.Eq(absPath)).FirstOrCreate()
+	cfg, err := q.Assign(field.Attrs(&model.Config{
+		Name: filepath.Base(absPath),
+	})).Where(q.Filepath.Eq(absPath)).FirstOrCreate()
 	if err != nil {
 		api.ErrHandler(c, err)
 		return