mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-13 07:56:14 +01:00
♻️ Plugin existence by plugin.json and cleanup persisted info (#17162)
This commit is contained in:
parent
82e552aafc
commit
2e8f6511e8
2 changed files with 6 additions and 20 deletions
|
|
@ -190,7 +190,7 @@ func loadBazaarInfo() (ret *BazaarInfo) {
|
|||
return
|
||||
}
|
||||
|
||||
// saveBazaarInfo 保存集市持久化信息(调用者需持有写锁)
|
||||
// saveBazaarInfo 保存集市持久化信息(调用者需持有 bazaarInfoCacheLock 写锁)
|
||||
func saveBazaarInfo() {
|
||||
infoPath := filepath.Join(util.DataDir, "storage", "bazaar.json")
|
||||
|
||||
|
|
|
|||
|
|
@ -267,9 +267,12 @@ func getPetals() (ret []*Petal) {
|
|||
var tmp []*Petal
|
||||
pluginsDir := filepath.Join(util.DataDir, "plugins")
|
||||
for _, petal := range ret {
|
||||
pluginPath := filepath.Join(pluginsDir, petal.Name)
|
||||
if hasPluginFiles(pluginPath) {
|
||||
pluginJSONPath := filepath.Join(pluginsDir, petal.Name, "plugin.json")
|
||||
if filelock.IsExist(pluginJSONPath) {
|
||||
tmp = append(tmp, petal)
|
||||
} else {
|
||||
// 插件不存在时,删除对应的持久化信息
|
||||
bazaar.RemovePackageInfo("plugins", petal.Name)
|
||||
}
|
||||
}
|
||||
if len(tmp) != len(ret) {
|
||||
|
|
@ -281,20 +284,3 @@ func getPetals() (ret []*Petal) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
// hasPluginFiles 检查插件安装目录是否存在且包含文件
|
||||
func hasPluginFiles(pluginPath string) bool {
|
||||
if !filelock.IsExist(pluginPath) {
|
||||
return false
|
||||
}
|
||||
entries, err := os.ReadDir(pluginPath)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue