feat: 解决首次安装没有同步应用的BUG

This commit is contained in:
zhengkunwang223 2023-02-17 17:19:35 +08:00 committed by zhengkunwang223
parent 5ef011b619
commit 974dc56a16
5 changed files with 14 additions and 7 deletions

View File

@ -4,9 +4,6 @@ GOCLEAN=$(GOCMD) clean
GOARCH=amd64
GOOS=linux
GOARCH=$(shell go env GOARCH)
GOOS=$(shell go env GOOS )
BASE_PAH := $(shell pwd)
BUILD_PATH = $(BASE_PAH)/build
WEB_PATH=$(BASE_PAH)/frontend

View File

@ -1,6 +1,7 @@
package business
import (
"fmt"
"github.com/1Panel-dev/1Panel/backend/app/service"
"github.com/1Panel-dev/1Panel/backend/global"
)
@ -9,11 +10,16 @@ func Init() {
setting, err := service.NewISettingService().GetSettingInfo()
if err != nil {
global.LOG.Errorf("sync app error: %s", err.Error())
}
if setting.AppStoreVersion != "" {
return
}
if setting.AppStoreVersion != "" {
fmt.Println(setting.AppStoreVersion)
global.LOG.Info("do not sync")
return
}
global.LOG.Info("sync app start...")
if err := service.NewIAppService().SyncAppList(); err != nil {
global.LOG.Errorf("sync app error: %s", err.Error())
}
global.LOG.Info("sync app success")
}

View File

@ -143,7 +143,7 @@ var AddTableSetting = &gormigrate.Migration{
tx.Rollback()
return err
}
if err := tx.Create(&model.Setting{Key: "AppStoreVersion", Value: "0"}).Error; err != nil {
if err := tx.Create(&model.Setting{Key: "AppStoreVersion", Value: ""}).Error; err != nil {
return err
}
return nil

View File

@ -59,9 +59,10 @@ func Init() {
if err := v.Unmarshal(&serverConfig); err != nil {
panic(err)
}
if mode != "release" && serverConfig.System.BaseDir != "" {
if mode == "dev" && fileOp.Stat("/opt/1panel/conf/app.yaml") && serverConfig.System.BaseDir != "" {
baseDir = serverConfig.System.BaseDir
}
global.CONF = serverConfig
global.CONF.BaseDir = baseDir
global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel"

View File

@ -142,15 +142,18 @@ func (f FileOp) DownloadFileWithProcess(url, dst, key string) error {
resp, err := http.Get(url)
if err != nil {
global.LOG.Errorf("get download file [%s] error, err %s", dst, err.Error())
return err
}
header, err := http.Head(url)
if err != nil {
global.LOG.Errorf("get download file [%s] error, err %s", dst, err.Error())
return err
}
out, err := os.Create(dst)
if err != nil {
global.LOG.Errorf("create download file [%s] error, err %s", dst, err.Error())
return err
}
go func() {