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() {