Skip to content

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

:bug: After uninstalling the plugin, data synchronization does not uninstall it https://github.com/siyuan-note/siyuan/issues/11277

Daniel95764352f805
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index d88991db32..a3686a077b 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -1410,6 +1410,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
var upsertTrees int
// 可能需要重新加载部分功能
var needReloadFlashcard, needReloadOcrTexts, needReloadPlugin bool
+ upsertPluginSet := hashset.New()
for _, file := range mergeResult.Upserts {
upserts = append(upserts, file.Path)
if strings.HasPrefix(file.Path, "/storage/riff/") {
@@ -1428,12 +1429,19 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
needReloadPlugin = true
}
+ if strings.HasPrefix(file.Path, "/plugins/") {
+ if parts := strings.Split(file.Path, "/"); 2 < len(parts) {
+ needReloadPlugin = true
+ upsertPluginSet.Add(parts[2])
+ }
+ }
+
if strings.HasSuffix(file.Path, ".sy") {
upsertTrees++
}
}
- clearWidgetsDir := hashset.New()
+ removeWidgetDirSet, removePluginSet := hashset.New(), hashset.New()
for _, file := range mergeResult.Removes {
removes = append(removes, file.Path)
if strings.HasPrefix(file.Path, "/storage/riff/") {
@@ -1452,9 +1460,16 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
needReloadPlugin = true
}
+ if strings.HasPrefix(file.Path, "/plugins/") {
+ if parts := strings.Split(file.Path, "/"); 2 < len(parts) {
+ needReloadPlugin = true
+ removePluginSet.Add(parts[2])
+ }
+ }
+
if strings.HasPrefix(file.Path, "/widgets/") {
if parts := strings.Split(file.Path, "/"); 2 < len(parts) {
- clearWidgetsDir.Add(parts[2])
+ removeWidgetDirSet.Add(parts[2])
}
}
}
@@ -1468,10 +1483,10 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
}
if needReloadPlugin {
- pushReloadPlugin()
+ pushReloadPlugin(upsertPluginSet, removePluginSet)
}
- for _, widgetDir := range clearWidgetsDir.Values() {
+ for _, widgetDir := range removeWidgetDirSet.Values() {
widgetDirPath := filepath.Join(util.DataDir, "widgets", widgetDir.(string))
gulu.File.RemoveEmptyDirs(widgetDirPath)
}
@@ -2002,6 +2017,16 @@ func getCloudSpace() (stat *cloud.Stat, err error) {
return
}
-func pushReloadPlugin() {
- util.BroadcastByType("main", "reloadPlugin", 0, "", nil)
+func pushReloadPlugin(upsertPluginSet, removePluginNameSet *hashset.Set) {
+ var upsertPlugins, removePlugins []string
+ for _, n := range upsertPluginSet.Values() {
+ upsertPlugins = append(upsertPlugins, n.(string))
+ }
+ for _, n := range removePluginNameSet.Values() {
+ removePlugins = append(removePlugins, n.(string))
+ }
+ util.BroadcastByType("main", "reloadPlugin", 0, "", map[string]interface{}{
+ "upsertPlugins": upsertPlugins,
+ "removePlugins": removePlugins,
+ })
}