An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve assets data index updating after data sync on mobile https://github.com/siyuan-note/siyuan/issues/16747
Daniel911a9d0ad0f3
diff --git a/kernel/model/assets.go b/kernel/model/assets.goindex 601d48b131..32b89f0e4c 100644--- a/kernel/model/assets.go+++ b/kernel/model/assets.go@@ -65,11 +65,19 @@ func GetAssetPathByHash(hash string) string {}func HandleAssetsRemoveEvent(assetAbsPath string) {+ if !filelock.IsExist(assetAbsPath) {+ return+ }+removeIndexAssetContent(assetAbsPath)removeAssetThumbnail(assetAbsPath)}func HandleAssetsChangeEvent(assetAbsPath string) {+ if !filelock.IsExist(assetAbsPath) {+ return+ }+indexAssetContent(assetAbsPath)removeAssetThumbnail(assetAbsPath)}@@ -694,7 +702,11 @@ func RemoveUnusedAssets() (ret []string) {util.PushErrMsg(fmt.Sprintf("%s", removeErr), 7000)return}+util.RemoveAssetText(unusedAsset)+ if !isFileWatcherAvailable() {+ HandleAssetsRemoveEvent(absPath)+ }}ret = append(ret, absPath)}@@ -739,6 +751,9 @@ func RemoveUnusedAsset(p string) (ret string) {ret = absPathutil.RemoveAssetText(p)+ if !isFileWatcherAvailable() {+ HandleAssetsRemoveEvent(absPath)+ }IncSync()diff --git a/kernel/model/assets_watcher.go b/kernel/model/assets_watcher.goindex 5a9953d2a1..a7d1b7ed99 100644--- a/kernel/model/assets_watcher.go+++ b/kernel/model/assets_watcher.go@@ -30,10 +30,14 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+func isFileWatcherAvailable() bool {+ return util.ContainerAndroid != util.Container && util.ContainerIOS != util.Container && util.ContainerHarmony != util.Container+}+var assetsWatcher *fsnotify.Watcherfunc WatchAssets() {- if util.ContainerAndroid == util.Container || util.ContainerIOS == util.Container || util.ContainerHarmony == util.Container {+ if !isFileWatcherAvailable() {return}diff --git a/kernel/model/repository.go b/kernel/model/repository.goindex 830663c335..e7486ac187 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -1635,6 +1635,11 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,if strings.HasSuffix(file.Path, ".sy") {upsertTrees++}++ if !isFileWatcherAvailable() && strings.HasPrefix(file.Path, "/assets/") {+ absPath := filepath.Join(util.DataDir, file.Path)+ HandleAssetsChangeEvent(absPath)+ }}removeWidgetDirSet, unloadPluginSet, uninstallPluginSet := hashset.New(), hashset.New(), hashset.New()@@ -1676,6 +1681,11 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,removeWidgetDirSet.Add(parts[2])}}++ if !isFileWatcherAvailable() && strings.HasPrefix(file.Path, "/assets/") {+ absPath := filepath.Join(util.DataDir, file.Path)+ HandleAssetsRemoveEvent(absPath)+ }}for _, upsertPetal := range mergeResult.UpsertPetals {