Skip to content

Commit

Permalink
🎨 Supports converting network assets in the database to local #12096
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jul 26, 2024
1 parent b4ece87 commit 1f46d16
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions kernel/model/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,35 @@ func setAssetsLinkDest(node *ast.Node, oldDest, dest string) {
node.TextMarkAHref = strings.ReplaceAll(node.TextMarkAHref, oldDest, dest)
} else if ast.NodeAudio == node.Type || ast.NodeVideo == node.Type {
node.Tokens = bytes.ReplaceAll(node.Tokens, []byte(oldDest), []byte(dest))
} else if ast.NodeAttributeView == node.Type {
needWrite := false
attrView, _ := av.ParseAttributeView(node.AttributeViewID)
if nil == attrView {
return
}

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 {
if oldDest == asset.Content && oldDest != dest {
asset.Content = dest
needWrite = true
}
}
}
}

if needWrite {
av.SaveAttributeView(attrView)
}
}
}

Expand Down

0 comments on commit 1f46d16

Please sign in to comment.