mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🐛 After uninstalling the plugin, data synchronization does not uninstall it https://github.com/siyuan-note/siyuan/issues/11277
This commit is contained in:
parent
0dec8802bc
commit
95764352f8
1 changed files with 31 additions and 6 deletions
|
|
@ -1410,6 +1410,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
||||||
var upsertTrees int
|
var upsertTrees int
|
||||||
// 可能需要重新加载部分功能
|
// 可能需要重新加载部分功能
|
||||||
var needReloadFlashcard, needReloadOcrTexts, needReloadPlugin bool
|
var needReloadFlashcard, needReloadOcrTexts, needReloadPlugin bool
|
||||||
|
upsertPluginSet := hashset.New()
|
||||||
for _, file := range mergeResult.Upserts {
|
for _, file := range mergeResult.Upserts {
|
||||||
upserts = append(upserts, file.Path)
|
upserts = append(upserts, file.Path)
|
||||||
if strings.HasPrefix(file.Path, "/storage/riff/") {
|
if strings.HasPrefix(file.Path, "/storage/riff/") {
|
||||||
|
|
@ -1428,12 +1429,19 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
||||||
needReloadPlugin = true
|
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") {
|
if strings.HasSuffix(file.Path, ".sy") {
|
||||||
upsertTrees++
|
upsertTrees++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearWidgetsDir := hashset.New()
|
removeWidgetDirSet, removePluginSet := hashset.New(), hashset.New()
|
||||||
for _, file := range mergeResult.Removes {
|
for _, file := range mergeResult.Removes {
|
||||||
removes = append(removes, file.Path)
|
removes = append(removes, file.Path)
|
||||||
if strings.HasPrefix(file.Path, "/storage/riff/") {
|
if strings.HasPrefix(file.Path, "/storage/riff/") {
|
||||||
|
|
@ -1452,9 +1460,16 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
||||||
needReloadPlugin = true
|
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 strings.HasPrefix(file.Path, "/widgets/") {
|
||||||
if parts := strings.Split(file.Path, "/"); 2 < len(parts) {
|
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 {
|
if needReloadPlugin {
|
||||||
pushReloadPlugin()
|
pushReloadPlugin(upsertPluginSet, removePluginSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, widgetDir := range clearWidgetsDir.Values() {
|
for _, widgetDir := range removeWidgetDirSet.Values() {
|
||||||
widgetDirPath := filepath.Join(util.DataDir, "widgets", widgetDir.(string))
|
widgetDirPath := filepath.Join(util.DataDir, "widgets", widgetDir.(string))
|
||||||
gulu.File.RemoveEmptyDirs(widgetDirPath)
|
gulu.File.RemoveEmptyDirs(widgetDirPath)
|
||||||
}
|
}
|
||||||
|
|
@ -2002,6 +2017,16 @@ func getCloudSpace() (stat *cloud.Stat, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func pushReloadPlugin() {
|
func pushReloadPlugin(upsertPluginSet, removePluginNameSet *hashset.Set) {
|
||||||
util.BroadcastByType("main", "reloadPlugin", 0, "", nil)
|
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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue