This commit is contained in:
Daniel 2023-06-30 10:26:25 +08:00
parent d94893f9a6
commit ba3f5fe5e5
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 6 additions and 3 deletions

View file

@ -108,7 +108,7 @@ func Plugins(frontend string) (plugins []*Plugin) {
return
}
func IsIncompatibleInstalledPlugin(name, frontend string) (found, incompatible bool) {
func ParseInstalledPlugin(name, frontend string) (found bool, displayName string, incompatible bool) {
pluginsPath := filepath.Join(util.DataDir, "plugins")
if !util.IsPathRegularDirOrSymlinkDir(pluginsPath) {
return
@ -135,6 +135,7 @@ func IsIncompatibleInstalledPlugin(name, frontend string) (found, incompatible b
}
found = true
displayName = getPreferredName(plugin.Package)
incompatible = isIncompatiblePlugin(plugin, frontend)
}
return

View file

@ -32,6 +32,7 @@ import (
// Petal represents a plugin's management status.
type Petal struct {
Name string `json:"name"` // Plugin name
DisplayName string `json:"displayName"` // Plugin display name
Enabled bool `json:"enabled"` // Whether enabled
Incompatible bool `json:"incompatible"` // Whether incompatible
@ -43,7 +44,7 @@ type Petal struct {
func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, err error) {
petals := getPetals()
found, incompatible := bazaar.IsIncompatibleInstalledPlugin(name, frontend)
found, displayName, incompatible := bazaar.ParseInstalledPlugin(name, frontend)
if !found {
logging.LogErrorf("plugin [%s] not found", name)
return
@ -56,6 +57,7 @@ func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, er
}
petals = append(petals, ret)
}
ret.DisplayName = displayName
ret.Enabled = enabled
ret.Incompatible = incompatible
@ -78,7 +80,7 @@ func LoadPetals(frontend string) (ret []*Petal) {
petals := getPetals()
for _, petal := range petals {
_, petal.Incompatible = bazaar.IsIncompatibleInstalledPlugin(petal.Name, frontend)
_, petal.DisplayName, petal.Incompatible = bazaar.ParseInstalledPlugin(petal.Name, frontend)
if !petal.Enabled || petal.Incompatible {
continue
}