From 974dc56a166c02b309ceacb54f5d34ad70cae298 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Fri, 17 Feb 2023 17:19:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=A3=E5=86=B3=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=B2=A1=E6=9C=89=E5=90=8C=E6=AD=A5=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 --- backend/init/business/business.go | 6 ++++++ backend/init/migration/migrations/init.go | 2 +- backend/init/viper/viper.go | 3 ++- backend/utils/files/file_op.go | 3 +++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c49aac79e..ec892815f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/backend/init/business/business.go b/backend/init/business/business.go index daa87bbe8..35bc0f33a 100644 --- a/backend/init/business/business.go +++ b/backend/init/business/business.go @@ -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()) + 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") } diff --git a/backend/init/migration/migrations/init.go b/backend/init/migration/migrations/init.go index 38c68de75..c58c99dce 100644 --- a/backend/init/migration/migrations/init.go +++ b/backend/init/migration/migrations/init.go @@ -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 diff --git a/backend/init/viper/viper.go b/backend/init/viper/viper.go index 709e64dde..35d231850 100644 --- a/backend/init/viper/viper.go +++ b/backend/init/viper/viper.go @@ -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" diff --git a/backend/utils/files/file_op.go b/backend/utils/files/file_op.go index 8600d4943..4ce168bba 100644 --- a/backend/utils/files/file_op.go +++ b/backend/utils/files/file_op.go @@ -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() {