fix: 解决应用商店同步图标丢失的问题 (#4776)

This commit is contained in:
zhengkunwang 2024-04-28 22:10:44 +08:00 committed by GitHub
parent b0a3ecd3d2
commit a40116d991
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 3 deletions

View file

@ -728,6 +728,14 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
res.CanUpdate = true res.CanUpdate = true
return res, err return res, err
} }
apps, _ := appRepo.GetBy(appRepo.WithResource(constant.AppResourceRemote))
for _, app := range apps {
if app.Icon == "" {
res.CanUpdate = true
return res, err
}
}
list, err := getAppList() list, err := getAppList()
if err != nil { if err != nil {
return res, err return res, err
@ -836,12 +844,16 @@ func (a AppService) SyncAppListFromRemote() (err error) {
if err != nil { if err != nil {
return err return err
} }
defer iconRes.Body.Close()
body, err := io.ReadAll(iconRes.Body) body, err := io.ReadAll(iconRes.Body)
if err != nil { if err != nil {
return err return err
} }
iconStr := base64.StdEncoding.EncodeToString(body) iconStr := ""
if !strings.Contains(string(body), "xml") {
iconStr = base64.StdEncoding.EncodeToString(body)
}
_ = iconRes.Body.Close()
app.Icon = iconStr app.Icon = iconStr
app.TagsKey = l.AppProperty.Tags app.TagsKey = l.AppProperty.Tags
if l.AppProperty.Recommend > 0 { if l.AppProperty.Recommend > 0 {

View file

@ -1,6 +1,8 @@
package cron package cron
import ( import (
"fmt"
mathRand "math/rand"
"time" "time"
"github.com/1Panel-dev/1Panel/backend/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
@ -41,7 +43,7 @@ func Run() {
if _, err := global.Cron.AddJob("@daily", job.NewSSLJob()); err != nil { if _, err := global.Cron.AddJob("@daily", job.NewSSLJob()); err != nil {
global.LOG.Errorf("can not add ssl corn job: %s", err.Error()) global.LOG.Errorf("can not add ssl corn job: %s", err.Error())
} }
if _, err := global.Cron.AddJob("@daily", job.NewAppStoreJob()); err != nil { if _, err := global.Cron.AddJob(fmt.Sprintf("%v %v * * *", mathRand.Intn(60), mathRand.Intn(3)), job.NewAppStoreJob()); err != nil {
global.LOG.Errorf("can not add appstore corn job: %s", err.Error()) global.LOG.Errorf("can not add appstore corn job: %s", err.Error())
} }

View file

@ -27,6 +27,9 @@ var whiteUrlList = map[string]struct{}{
"/api/v1/databases/variables": {}, "/api/v1/databases/variables": {},
"/api/v1/databases/status": {}, "/api/v1/databases/status": {},
"/api/v1/databases/baseinfo": {}, "/api/v1/databases/baseinfo": {},
"/api/v1/waf/attack/stat": {},
"/api/v1/waf/config/website": {},
} }
func DemoHandle() gin.HandlerFunc { func DemoHandle() gin.HandlerFunc {