Fix executing the uninstall method when closing the plugin (#16522)

* 🐛 Fix executing the uninstall method when closing the plugin

* 后端推送区分插件禁用与卸载
This commit is contained in:
Jeffrey Chen 2025-12-13 10:37:05 +08:00 committed by GitHub
parent ab62a13cb0
commit ec881a76af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 54 additions and 26 deletions

View file

@ -1635,7 +1635,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
}
}
removeWidgetDirSet, removePluginSet := hashset.New(), hashset.New()
removeWidgetDirSet, unloadPluginSet, uninstallPluginSet := hashset.New(), hashset.New(), hashset.New()
for _, file := range mergeResult.Removes {
removes = append(removes, file.Path)
if strings.HasPrefix(file.Path, "/storage/riff/") {
@ -1664,7 +1664,8 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
if strings.HasPrefix(file.Path, "/plugins/") {
if parts := strings.Split(file.Path, "/"); 2 < len(parts) {
needReloadPlugin = true
removePluginSet.Add(parts[2])
// 删除插件目录:卸载
uninstallPluginSet.Add(parts[2])
}
}
@ -1681,7 +1682,8 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
}
for _, removePetal := range mergeResult.RemovePetals {
needReloadPlugin = true
removePluginSet.Add(removePetal)
// Petal 中删除插件:卸载
uninstallPluginSet.Add(removePetal)
}
if needReloadFlashcard {
@ -1693,7 +1695,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
}
if needReloadPlugin {
PushReloadPlugin(upsertCodePluginSet, upsertDataPluginSet, removePluginSet, "")
PushReloadPlugin(upsertCodePluginSet, upsertDataPluginSet, unloadPluginSet, uninstallPluginSet, "")
}
for _, widgetDir := range removeWidgetDirSet.Values() {