mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 插入/更新资源文件导致内核崩溃 https://github.com/siyuan-note/siyuan/issues/5574
This commit is contained in:
parent
c0df1e50d4
commit
caf2dc5231
6 changed files with 19 additions and 16 deletions
11
kernel/cache/asset.go
vendored
11
kernel/cache/asset.go
vendored
|
|
@ -33,11 +33,14 @@ type Asset struct {
|
|||
Updated int64 `json:"updated"`
|
||||
}
|
||||
|
||||
var Assets = sync.Map{}
|
||||
var Assets = map[string]*Asset{}
|
||||
var assetsLock = sync.Mutex{}
|
||||
|
||||
func LoadAssets() {
|
||||
start := time.Now()
|
||||
Assets = sync.Map{}
|
||||
assetsLock.Lock()
|
||||
defer assetsLock.Unlock()
|
||||
|
||||
assets := filepath.Join(util.DataDir, "assets")
|
||||
filepath.Walk(assets, func(path string, info fs.FileInfo, err error) error {
|
||||
if info.IsDir() {
|
||||
|
|
@ -52,11 +55,11 @@ func LoadAssets() {
|
|||
|
||||
hName := util.RemoveID(info.Name())
|
||||
path = filepath.ToSlash(strings.TrimPrefix(path, util.DataDir))[1:]
|
||||
Assets.Store(path, &Asset{
|
||||
Assets[path] = &Asset{
|
||||
HName: hName,
|
||||
Path: path,
|
||||
Updated: info.ModTime().UnixMilli(),
|
||||
})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
elapsed := time.Since(start)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue