2022-11-23 17:44:24 +08:00
|
|
|
package business
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/service"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/global"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Init() {
|
2023-03-20 10:38:39 +08:00
|
|
|
syncApp()
|
|
|
|
syncInstalledApp()
|
|
|
|
}
|
|
|
|
|
|
|
|
func syncApp() {
|
2023-02-13 15:38:09 +08:00
|
|
|
setting, err := service.NewISettingService().GetSettingInfo()
|
|
|
|
if err != nil {
|
|
|
|
global.LOG.Errorf("sync app error: %s", err.Error())
|
2023-02-17 17:19:35 +08:00
|
|
|
return
|
2023-02-13 15:38:09 +08:00
|
|
|
}
|
2023-02-17 16:21:13 +08:00
|
|
|
if setting.AppStoreVersion != "" {
|
2023-03-20 10:38:39 +08:00
|
|
|
global.LOG.Info("no need to sync")
|
2023-02-13 15:38:09 +08:00
|
|
|
return
|
|
|
|
}
|
2023-02-17 17:19:35 +08:00
|
|
|
global.LOG.Info("sync app start...")
|
2023-02-13 15:46:14 +08:00
|
|
|
if err := service.NewIAppService().SyncAppList(); err != nil {
|
2022-11-23 17:44:24 +08:00
|
|
|
global.LOG.Errorf("sync app error: %s", err.Error())
|
2023-03-20 10:38:39 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
global.LOG.Info("sync app successful")
|
|
|
|
}
|
|
|
|
|
|
|
|
func syncInstalledApp() {
|
|
|
|
if err := service.NewIAppInstalledService().SyncAll(true); err != nil {
|
|
|
|
global.LOG.Errorf("sync instaled app error: %s", err.Error())
|
2022-11-23 17:44:24 +08:00
|
|
|
}
|
|
|
|
}
|