Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
9d77953661
4 changed files with 62 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
FROM node:21 as NODE_BUILD
|
||||
WORKDIR /go/src/github.com/siyuan-note/siyuan/
|
||||
ADD . /go/src/github.com/siyuan-note/siyuan/
|
||||
RUN cd app && npm install -g pnpm && pnpm install && pnpm run build
|
||||
RUN cd app && npm install -g pnpm@9.0.2 && pnpm install && pnpm run build
|
||||
|
||||
FROM golang:alpine as GO_BUILD
|
||||
WORKDIR /go/src/github.com/siyuan-note/siyuan/
|
||||
|
|
|
@ -1343,6 +1343,8 @@ func unbindAttributeViewBlock(operation *Operation, tx *Transaction) (err error)
|
|||
if nil != value.Block {
|
||||
value.Block.ID = operation.NextID
|
||||
}
|
||||
|
||||
replaceRelationAvValues(operation.AvID, operation.ID, operation.NextID)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3022,6 +3024,8 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err error
|
|||
|
||||
if av.KeyTypeBlock == value.Type && !operation.IsDetached {
|
||||
bindBlockAv(tx, operation.AvID, operation.NextID)
|
||||
|
||||
replaceRelationAvValues(operation.AvID, operation.PreviousID, operation.NextID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3537,3 +3541,43 @@ func getAttrViewName(attrView *av.AttributeView) string {
|
|||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func replaceRelationAvValues(avID, previousID, nextID string) {
|
||||
// The database relation fields follow the change after the primary key field is changed https://github.com/siyuan-note/siyuan/issues/11117
|
||||
|
||||
srcAvIDs := av.GetSrcAvIDs(avID)
|
||||
for _, srcAvID := range srcAvIDs {
|
||||
srcAv, parseErr := av.ParseAttributeView(srcAvID)
|
||||
changed := false
|
||||
if nil != parseErr {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, srcKeyValues := range srcAv.KeyValues {
|
||||
if av.KeyTypeRelation != srcKeyValues.Key.Type {
|
||||
continue
|
||||
}
|
||||
|
||||
if avID != srcKeyValues.Key.Relation.AvID {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, srcValue := range srcKeyValues.Values {
|
||||
if nil == srcValue.Relation {
|
||||
continue
|
||||
}
|
||||
|
||||
srcAvChanged := false
|
||||
srcValue.Relation.BlockIDs, srcAvChanged = util.ReplaceStr(srcValue.Relation.BlockIDs, previousID, nextID)
|
||||
if srcAvChanged {
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if changed {
|
||||
av.SaveAttributeView(srcAv)
|
||||
util.PushReloadAttrView(srcAvID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ var cookieStore = cookie.NewStore([]byte("ATN51UlxVq1Gcvdf"))
|
|||
func Serve(fastMode bool) {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
ginServer := gin.New()
|
||||
ginServer.UseH2C = true
|
||||
ginServer.MaxMultipartMemory = 1024 * 1024 * 32 // 插入较大的资源文件时内存占用较大 https://github.com/siyuan-note/siyuan/issues/5023
|
||||
ginServer.Use(
|
||||
model.ControlConcurrency, // 请求串行化 Concurrency control when requesting the kernel API https://github.com/siyuan-note/siyuan/issues/9939
|
||||
|
@ -135,7 +136,7 @@ func Serve(fastMode bool) {
|
|||
|
||||
go util.HookUILoaded()
|
||||
|
||||
if err = http.Serve(ln, ginServer); nil != err {
|
||||
if err = http.Serve(ln, ginServer.Handler()); nil != err {
|
||||
if !fastMode {
|
||||
logging.LogErrorf("boot kernel failed: %s", err)
|
||||
os.Exit(logging.ExitCodeUnavailablePort)
|
||||
|
|
|
@ -135,3 +135,18 @@ func ContainsSubStr(s string, subStrs []string) bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ReplaceStr(strs []string, old, new string) (ret []string, changed bool) {
|
||||
if old == new {
|
||||
return strs, false
|
||||
}
|
||||
|
||||
for i, v := range strs {
|
||||
if v == old {
|
||||
strs[i] = new
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
ret = strs
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue