From b3a39d74a6028c88b108bea5c87229e61a6029c0 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 6 Jan 2026 12:17:41 +0800 Subject: [PATCH] :art: Improve assets data index updating after data sync on mobile https://github.com/siyuan-note/siyuan/issues/16747 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/assets.go | 8 ++++++++ kernel/model/assets_watcher.go | 13 ++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/kernel/model/assets.go b/kernel/model/assets.go index 31b2f86ce..413df999c 100644 --- a/kernel/model/assets.go +++ b/kernel/model/assets.go @@ -69,6 +69,10 @@ func HandleAssetsRemoveEvent(assetAbsPath string) { return } + if ".DS_Store" == filepath.Base(assetAbsPath) { + return + } + removeIndexAssetContent(assetAbsPath) removeAssetThumbnail(assetAbsPath) } @@ -78,6 +82,10 @@ func HandleAssetsChangeEvent(assetAbsPath string) { return } + if ".DS_Store" == filepath.Base(assetAbsPath) { + return + } + indexAssetContent(assetAbsPath) removeAssetThumbnail(assetAbsPath) } diff --git a/kernel/model/assets_watcher.go b/kernel/model/assets_watcher.go index 174a7b504..051aaab2c 100644 --- a/kernel/model/assets_watcher.go +++ b/kernel/model/assets_watcher.go @@ -21,6 +21,7 @@ package model import ( "os" "path/filepath" + "strings" "time" "github.com/88250/gulu" @@ -71,21 +72,19 @@ func watchAssets() { return } + if strings.HasSuffix(event.Name, ".tmp") { + continue + } + lastEvent = event timer.Reset(time.Millisecond * 100) - - if lastEvent.Op&fsnotify.Rename == fsnotify.Rename || lastEvent.Op&fsnotify.Write == fsnotify.Write { - HandleAssetsChangeEvent(lastEvent.Name) - } else if lastEvent.Op&fsnotify.Remove == fsnotify.Remove { - HandleAssetsRemoveEvent(lastEvent.Name) - } case err, ok := <-assetsWatcher.Errors: if !ok { return } logging.LogErrorf("watch assets failed: %s", err) case <-timer.C: - //logging.LogInfof("assets changed: %s", lastEvent) + logging.LogInfof("assets changed: %s", lastEvent) if lastEvent.Op&fsnotify.Write == fsnotify.Write { IncSync() }