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

pull/148/head
zhengkunwang223 2 years ago committed by zhengkunwang223
parent 5ef011b619
commit 974dc56a16

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

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

@ -143,7 +143,7 @@ var AddTableSetting = &gormigrate.Migration{
tx.Rollback() tx.Rollback()
return err 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 err
} }
return nil return nil

@ -59,9 +59,10 @@ func Init() {
if err := v.Unmarshal(&serverConfig); err != nil { if err := v.Unmarshal(&serverConfig); err != nil {
panic(err) 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 baseDir = serverConfig.System.BaseDir
} }
global.CONF = serverConfig global.CONF = serverConfig
global.CONF.BaseDir = baseDir global.CONF.BaseDir = baseDir
global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel" global.CONF.System.DataDir = global.CONF.BaseDir + "/1panel"

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

Loading…
Cancel
Save