Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: After uninstalling the widget, data synchronization does not clear the widget folder https://github.com/siyuan-note/siyuan/issues/11279

Daniel6a451cf1dab2
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index f7cf064e3d..0c0947856c 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -41,6 +41,7 @@ import (
"github.com/88250/lute/html"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
+ "github.com/emirpasic/gods/sets/hashset"
"github.com/siyuan-note/dejavu"
"github.com/siyuan-note/dejavu/cloud"
"github.com/siyuan-note/dejavu/entity"
@@ -1427,6 +1428,8 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
upsertTrees++
}
}
+
+ clearWidgetsDir := hashset.New()
for _, file := range mergeResult.Removes {
removes = append(removes, file.Path)
if strings.HasPrefix(file.Path, "/storage/riff/") {
@@ -1444,6 +1447,12 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
if strings.HasPrefix(file.Path, "/storage/petal/") {
needReloadPlugin = true
}
+
+ if strings.HasPrefix(file.Path, "/widgets/") {
+ if parts := strings.Split(file.Path, "/"); 2 < len(parts) {
+ clearWidgetsDir.Add(parts[2])
+ }
+ }
}
if needReloadFlashcard {
@@ -1458,6 +1467,11 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
pushReloadPlugin()
}
+ for _, widgetDir := range clearWidgetsDir.Values() {
+ widgetDirPath := filepath.Join(util.DataDir, "widgets", widgetDir.(string))
+ gulu.File.RemoveEmptyDirs(widgetDirPath)
+ }
+
syncingFiles = sync.Map{}
syncingStorages.Store(false)