From 3fecf9eb20799b9b6c7d4b6064f07a99365d2905 Mon Sep 17 00:00:00 2001 From: Jacky Date: Sun, 15 Dec 2024 15:54:39 +0800 Subject: [PATCH] fix: maybe fail to sync config to remote node #775 --- api/config/modify.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/config/modify.go b/api/config/modify.go index 71fe078d..4f9734b4 100644 --- a/api/config/modify.go +++ b/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