🎨 Improve minimum version requirements for marketplace packages https://github.com/siyuan-note/siyuan/issues/16688

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-12-30 17:27:23 +08:00
parent a92f8b5479
commit 818846025b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
7 changed files with 101 additions and 20 deletions

View file

@ -88,6 +88,8 @@ func Plugins(frontend string) (plugins []*Plugin) {
}
plugin.DisallowInstall = disallowInstallBazaarPackage(plugin.Package)
plugin.DisallowUpdate = disallowInstallBazaarPackage(plugin.Package)
plugin.UpdateRequiredMinAppVer = plugin.MinAppVersion
plugin.Incompatible = isIncompatiblePlugin(plugin, frontend)
plugin.URL = strings.TrimSuffix(plugin.URL, "/")
@ -166,7 +168,7 @@ func ParseInstalledPlugin(name, frontend string) (found bool, displayName string
return
}
func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
func InstalledPlugins(frontend string) (ret []*Plugin) {
ret = []*Plugin{}
pluginsPath := filepath.Join(util.DataDir, "plugins")
@ -180,10 +182,7 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
return
}
var bazaarPlugins []*Plugin
if checkUpdate {
bazaarPlugins = Plugins(frontend)
}
bazaarPlugins := Plugins(frontend)
for _, pluginDir := range pluginDirs {
if !util.IsDirRegularOrSymlink(pluginDir) {
@ -197,6 +196,10 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
}
plugin.DisallowInstall = disallowInstallBazaarPackage(plugin.Package)
if bazaarPkg := getBazaarPlugin(plugin.Name, bazaarPlugins); nil != bazaarPkg {
plugin.DisallowUpdate = disallowInstallBazaarPackage(bazaarPkg.Package)
plugin.UpdateRequiredMinAppVer = bazaarPkg.MinAppVersion
}
installPath := filepath.Join(util.DataDir, "plugins", dirName)
plugin.Installed = true
@ -229,6 +232,15 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
return
}
func getBazaarPlugin(name string, plugins []*Plugin) *Plugin {
for _, p := range plugins {
if p.Name == name {
return p
}
}
return nil
}
func InstallPlugin(repoURL, repoHash, installPath string, systemID string) error {
repoURLHash := repoURL + "@" + repoHash
data, err := downloadPackage(repoURLHash, true, systemID)