mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40: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
|
|
@ -20,7 +20,6 @@ import (
|
|||
"crypto/sha256"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
|
@ -71,12 +70,11 @@ func docTitleImgAsset(root *ast.Node) *Asset {
|
|||
}
|
||||
|
||||
var hash string
|
||||
var err error
|
||||
absPath := filepath.Join(util.DataDir, p)
|
||||
if data, err := os.ReadFile(absPath); nil != err {
|
||||
if hash, err = util.GetEtag(absPath); nil != err {
|
||||
util.LogErrorf("read asset [%s] data failed: %s", absPath, err)
|
||||
hash = fmt.Sprintf("%x", sha256.Sum256([]byte(gulu.Rand.String(7))))
|
||||
} else {
|
||||
hash = fmt.Sprintf("%x", sha256.Sum256(data))
|
||||
}
|
||||
name, _ := util.LastID(p)
|
||||
asset := &Asset{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue