mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-08 00:04:21 +01:00
⚡ Improve data indexing to reduce disk read operations https://github.com/siyuan-note/siyuan/issues/16958
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
dc00060062
commit
87282404bb
4 changed files with 65 additions and 45 deletions
|
|
@ -93,6 +93,13 @@ func HandleAssetsRemoveEvent(assetAbsPath string) {
|
|||
|
||||
removeIndexAssetContent(assetAbsPath)
|
||||
removeAssetThumbnail(assetAbsPath)
|
||||
|
||||
hash, err := util.GetEtag(assetAbsPath)
|
||||
if nil != err {
|
||||
logging.LogErrorf("calc asset [%s] hash failed: %s", assetAbsPath, err)
|
||||
} else {
|
||||
cache.RemoveAssetHash(hash)
|
||||
}
|
||||
}
|
||||
|
||||
func HandleAssetsChangeEvent(assetAbsPath string) {
|
||||
|
|
@ -106,6 +113,15 @@ func HandleAssetsChangeEvent(assetAbsPath string) {
|
|||
|
||||
indexAssetContent(assetAbsPath)
|
||||
removeAssetThumbnail(assetAbsPath)
|
||||
|
||||
hash, err := util.GetEtag(assetAbsPath)
|
||||
if nil != err {
|
||||
logging.LogErrorf("calc asset [%s] hash failed: %s", assetAbsPath, err)
|
||||
} else {
|
||||
p := strings.TrimPrefix(assetAbsPath, util.DataDir)
|
||||
p = filepath.ToSlash(p)
|
||||
cache.SetAssetHash(hash, p)
|
||||
}
|
||||
}
|
||||
|
||||
func removeAssetThumbnail(assetAbsPath string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue