Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 25, 2024
2 parents a3ff944 + 1f011dc commit b305181
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 46 deletions.
80 changes: 37 additions & 43 deletions kernel/model/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ func UploadAssets2Cloud(rootID string) (count int, err error) {
assets := assetsLinkDestsInTree(tree)
embedAssets := assetsLinkDestsInQueryEmbedNodes(tree)
assets = append(assets, embedAssets...)
avAssets := assetsLinkDestsInAttributeViewNodes(tree)
assets = append(assets, avAssets...)
assets = gulu.Str.RemoveDuplicatedElem(assets)
count, err = uploadAssets2Cloud(assets, bizTypeUploadAssets)
if err != nil {
Expand Down Expand Up @@ -913,46 +911,6 @@ func emojisInTree(tree *parse.Tree) (ret []string) {
return
}

func assetsLinkDestsInAttributeViewNodes(tree *parse.Tree) (ret []string) {
// The images in the databases are not uploaded to the community hosting https://github.com/siyuan-note/siyuan/issues/11948

ret = []string{}
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering || ast.NodeAttributeView != n.Type {
return ast.WalkContinue
}

attrView, _ := av.ParseAttributeView(n.AttributeViewID)
if nil == attrView {
return ast.WalkContinue
}

for _, keyValues := range attrView.KeyValues {
if av.KeyTypeMAsset != keyValues.Key.Type {
continue
}

for _, value := range keyValues.Values {
if 1 > len(value.MAsset) {
continue
}

for _, asset := range value.MAsset {
dest := asset.Content
if !treenode.IsRelativePath([]byte(dest)) {
continue
}

ret = append(ret, strings.TrimSpace(dest))
}
}
}
return ast.WalkContinue
})
ret = gulu.Str.RemoveDuplicatedElem(ret)
return
}

func assetsLinkDestsInQueryEmbedNodes(tree *parse.Tree) (ret []string) {
// The images in the embed blocks are not uploaded to the community hosting https://github.com/siyuan-note/siyuan/issues/10042

Expand Down Expand Up @@ -1010,7 +968,7 @@ func assetsLinkDestsInNode(node *ast.Node) (ret []string) {
// 修改以下代码时需要同时修改 database 构造行级元素实现,增加必要的类型
if !entering || (ast.NodeLinkDest != n.Type && ast.NodeHTMLBlock != n.Type && ast.NodeInlineHTML != n.Type &&
ast.NodeIFrame != n.Type && ast.NodeWidget != n.Type && ast.NodeAudio != n.Type && ast.NodeVideo != n.Type &&
!n.IsTextMarkType("a") && !n.IsTextMarkType("file-annotation-ref")) {
ast.NodeAttributeView != n.Type && !n.IsTextMarkType("a") && !n.IsTextMarkType("file-annotation-ref")) {
return ast.WalkContinue
}

Expand Down Expand Up @@ -1040,6 +998,42 @@ func assetsLinkDestsInNode(node *ast.Node) (ret []string) {
dest := n.TextMarkFileAnnotationRefID[:strings.LastIndexByte(n.TextMarkFileAnnotationRefID, '/')]
dest = strings.TrimSpace(dest)
ret = append(ret, dest)
} else if ast.NodeAttributeView == n.Type {
attrView, _ := av.ParseAttributeView(n.AttributeViewID)
if nil == attrView {
return ast.WalkContinue
}

for _, keyValues := range attrView.KeyValues {
if av.KeyTypeMAsset == keyValues.Key.Type {
for _, value := range keyValues.Values {
if 1 > len(value.MAsset) {
continue
}

for _, asset := range value.MAsset {
dest := asset.Content
if !treenode.IsRelativePath([]byte(dest)) {
continue
}

ret = append(ret, strings.TrimSpace(dest))
}
}
} else if av.KeyTypeURL == keyValues.Key.Type {
for _, value := range keyValues.Values {
if nil != value.URL {
dest := value.URL.Content
if !treenode.IsRelativePath([]byte(dest)) {
continue
}

ret = append(ret, strings.TrimSpace(dest))
}
}
}

}
} else {
if ast.NodeWidget == n.Type {
dataAssets := n.IALAttr("custom-data-assets")
Expand Down
2 changes: 0 additions & 2 deletions kernel/model/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ func Export2Liandi(id string) (err error) {
assets := assetsLinkDestsInTree(tree)
embedAssets := assetsLinkDestsInQueryEmbedNodes(tree)
assets = append(assets, embedAssets...)
avAssets := assetsLinkDestsInAttributeViewNodes(tree)
assets = append(assets, avAssets...)
assets = gulu.Str.RemoveDuplicatedElem(assets)
_, err = uploadAssets2Cloud(assets, bizTypeExport2Liandi)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion kernel/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,6 @@ func fullTextSearchByFTSWithRoot(query, boxFilter, pathFilter, typeFilter, ignor
for j, block := range blocks {
if resultBlock.ID == block.ID {
resultBlocks[i] = block
// 减少 blocks
blocks = append(blocks[:j], blocks[j+1:]...)
break
}
Expand Down

0 comments on commit b305181

Please sign in to comment.