mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🐛 The doc title image index failed when using notebook-level assets https://github.com/siyuan-note/siyuan/issues/9936
This commit is contained in:
parent
f58623af6b
commit
7b16c45c8e
2 changed files with 9 additions and 6 deletions
|
|
@ -62,7 +62,7 @@ func docTagSpans(n *ast.Node) (ret []*Span) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func docTitleImgAsset(root *ast.Node) *Asset {
|
func docTitleImgAsset(root *ast.Node, boxLocalPath, docDirLocalPath string) *Asset {
|
||||||
if p := treenode.GetDocTitleImgPath(root); "" != p {
|
if p := treenode.GetDocTitleImgPath(root); "" != p {
|
||||||
if !util.IsAssetLinkDest([]byte(p)) {
|
if !util.IsAssetLinkDest([]byte(p)) {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -70,11 +70,14 @@ func docTitleImgAsset(root *ast.Node) *Asset {
|
||||||
|
|
||||||
var hash string
|
var hash string
|
||||||
var err error
|
var err error
|
||||||
absPath := filepath.Join(util.DataDir, p)
|
if lp := assetLocalPath(p, boxLocalPath, docDirLocalPath); "" != lp {
|
||||||
if hash, err = util.GetEtag(absPath); nil != err {
|
hash, err = util.GetEtag(lp)
|
||||||
logging.LogErrorf("read asset [%s] data failed: %s", absPath, err)
|
if nil != err {
|
||||||
|
logging.LogErrorf("calc asset [%s] hash failed: %s", lp, err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
name, _ := util.LastID(p)
|
name, _ := util.LastID(p)
|
||||||
asset := &Asset{
|
asset := &Asset{
|
||||||
ID: ast.NewNodeID(),
|
ID: ast.NewNodeID(),
|
||||||
|
|
|
||||||
|
|
@ -683,7 +683,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
|
||||||
walkStatus = ast.WalkSkipChildren
|
walkStatus = ast.WalkSkipChildren
|
||||||
return
|
return
|
||||||
case ast.NodeDocument:
|
case ast.NodeDocument:
|
||||||
if asset := docTitleImgAsset(n); nil != asset {
|
if asset := docTitleImgAsset(n, boxLocalPath, docDirLocalPath); nil != asset {
|
||||||
assets = append(assets, asset)
|
assets = append(assets, asset)
|
||||||
}
|
}
|
||||||
if tags := docTagSpans(n); 0 < len(tags) {
|
if tags := docTagSpans(n); 0 < len(tags) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue