mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 插入较大的资源文件时内存占用较大 https://github.com/siyuan-note/siyuan/issues/5023
This commit is contained in:
parent
dc46b478bc
commit
49b9f7bc92
7 changed files with 137 additions and 103 deletions
|
|
@ -18,10 +18,8 @@ package sql
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
|
@ -522,12 +520,12 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
|
|||
}
|
||||
|
||||
var hash string
|
||||
var hashErr error
|
||||
if lp := assetLocalPath(dest, boxLocalPath, docDirLocalPath); "" != lp {
|
||||
if !gulu.File.IsDir(lp) {
|
||||
if data, err := os.ReadFile(lp); nil != err {
|
||||
util.LogErrorf("read asset [%s] data failed: %s", lp, err)
|
||||
} else {
|
||||
hash = fmt.Sprintf("%x", sha256.Sum256(data))
|
||||
hash, hashErr = util.GetEtag(lp)
|
||||
if nil != hashErr {
|
||||
util.LogErrorf("calc asset [%s] hash failed: %s", lp, hashErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -597,11 +595,11 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
|
|||
|
||||
dest := string(src)
|
||||
var hash string
|
||||
var hashErr error
|
||||
if lp := assetLocalPath(dest, boxLocalPath, docDirLocalPath); "" != lp {
|
||||
if data, err := os.ReadFile(lp); nil != err {
|
||||
util.LogErrorf("read asset [%s] data failed: %s", lp, err)
|
||||
} else {
|
||||
hash = fmt.Sprintf("%x", sha256.Sum256(data))
|
||||
hash, hashErr = util.GetEtag(lp)
|
||||
if nil != hashErr {
|
||||
util.LogErrorf("calc asset [%s] hash failed: %s", lp, hashErr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue