mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Improve petals loading https://github.com/siyuan-note/siyuan/issues/13472
This commit is contained in:
parent
0a87b9aed8
commit
7acf83acc9
2 changed files with 22 additions and 3 deletions
|
|
@ -253,9 +253,6 @@ func UninstallBazaarPlugin(pluginName, frontend string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
petals = tmp
|
petals = tmp
|
||||||
if 1 > len(petals) {
|
|
||||||
petals = []*Petal{}
|
|
||||||
}
|
|
||||||
savePetals(petals)
|
savePetals(petals)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,13 @@ var petalsStoreLock = sync.Mutex{}
|
||||||
func savePetals(petals []*Petal) {
|
func savePetals(petals []*Petal) {
|
||||||
petalsStoreLock.Lock()
|
petalsStoreLock.Lock()
|
||||||
defer petalsStoreLock.Unlock()
|
defer petalsStoreLock.Unlock()
|
||||||
|
savePetals0(petals)
|
||||||
|
}
|
||||||
|
|
||||||
|
func savePetals0(petals []*Petal) {
|
||||||
|
if 1 > len(petals) {
|
||||||
|
petals = []*Petal{}
|
||||||
|
}
|
||||||
|
|
||||||
petalDir := filepath.Join(util.DataDir, "storage", "petal")
|
petalDir := filepath.Join(util.DataDir, "storage", "petal")
|
||||||
confPath := filepath.Join(petalDir, "petals.json")
|
confPath := filepath.Join(petalDir, "petals.json")
|
||||||
|
|
@ -233,6 +240,21 @@ func getPetals() (ret []*Petal) {
|
||||||
logging.LogErrorf("unmarshal petals failed: %s", err)
|
logging.LogErrorf("unmarshal petals failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tmp []*Petal
|
||||||
|
pluginsDir := filepath.Join(util.DataDir, "plugins")
|
||||||
|
for _, petal := range ret {
|
||||||
|
if petal.Enabled && filelock.IsExist(filepath.Join(pluginsDir, petal.Name)) {
|
||||||
|
tmp = append(tmp, petal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(tmp) != len(ret) {
|
||||||
|
savePetals0(tmp)
|
||||||
|
ret = tmp
|
||||||
|
}
|
||||||
|
if 1 > len(ret) {
|
||||||
|
ret = []*Petal{}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue