mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🐛 删除未引用资源后已删除的资源仍能搜索到 Fix https://github.com/siyuan-note/siyuan/issues/6737
This commit is contained in:
parent
05ee2250c0
commit
862b740e7a
2 changed files with 31 additions and 13 deletions
20
kernel/cache/asset.go
vendored
20
kernel/cache/asset.go
vendored
|
|
@ -33,9 +33,24 @@ type Asset struct {
|
|||
Updated int64 `json:"updated"`
|
||||
}
|
||||
|
||||
var Assets = map[string]*Asset{}
|
||||
var assetsCache = map[string]*Asset{}
|
||||
var assetsLock = sync.Mutex{}
|
||||
|
||||
func GetAssets() (ret map[string]*Asset) {
|
||||
assetsLock.Lock()
|
||||
defer assetsLock.Unlock()
|
||||
|
||||
ret = assetsCache
|
||||
return
|
||||
}
|
||||
|
||||
func RemoveAsset(path string) {
|
||||
assetsLock.Lock()
|
||||
defer assetsLock.Unlock()
|
||||
|
||||
delete(assetsCache, path)
|
||||
}
|
||||
|
||||
func LoadAssets() {
|
||||
defer logging.Recover()
|
||||
|
||||
|
|
@ -43,6 +58,7 @@ func LoadAssets() {
|
|||
assetsLock.Lock()
|
||||
defer assetsLock.Unlock()
|
||||
|
||||
assetsCache = map[string]*Asset{}
|
||||
assets := util.GetDataAssetsAbsPath()
|
||||
filepath.Walk(assets, func(path string, info fs.FileInfo, err error) error {
|
||||
if nil == info {
|
||||
|
|
@ -60,7 +76,7 @@ func LoadAssets() {
|
|||
|
||||
hName := util.RemoveID(info.Name())
|
||||
path = "assets" + filepath.ToSlash(strings.TrimPrefix(path, assets))
|
||||
Assets[path] = &Asset{
|
||||
assetsCache[path] = &Asset{
|
||||
HName: hName,
|
||||
Path: path,
|
||||
Updated: info.ModTime().UnixMilli(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue