From 90a5e741fdfb8e4e757c75d854666068733230d9 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 2 Jun 2023 10:26:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=8D=87=E7=BA=A7=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#1226)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app.go | 28 ++++++++++--------- backend/app/service/app_utils.go | 5 ---- frontend/src/components/status/index.vue | 2 ++ .../src/views/app-store/installed/index.vue | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/backend/app/service/app.go b/backend/app/service/app.go index cc7196b75..afb9b9a3d 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -390,7 +390,11 @@ func (a AppService) SyncAppListFromLocal() { if dirEntry.IsDir() { appDir := path.Join(localAppDir, dirEntry.Name()) appDirEntries, err := os.ReadDir(appDir) - app, err := handleLocalApp(localAppDir) + if err != nil { + global.LOG.Errorf(i18n.GetMsgWithMap("ErrAppDirNull", map[string]interface{}{"name": dirEntry.Name(), "err": err.Error()})) + continue + } + app, err := handleLocalApp(appDir) if err != nil { global.LOG.Errorf(i18n.GetMsgWithMap("LocalAppErr", map[string]interface{}{"name": dirEntry.Name(), "err": err.Error()})) continue @@ -491,29 +495,27 @@ func (a AppService) SyncAppListFromLocal() { tx, ctx := getTxAndContext() defer tx.Rollback() if len(newApps) > 0 { - if err := appRepo.BatchCreate(ctx, newApps); err != nil { + if err = appRepo.BatchCreate(ctx, newApps); err != nil { return } } for _, update := range updateApps { - if err := appRepo.Save(ctx, &update); err != nil { + if err = appRepo.Save(ctx, &update); err != nil { return } } if len(deleteApps) > 0 { - if err := appRepo.BatchDelete(ctx, deleteApps); err != nil { + if err = appRepo.BatchDelete(ctx, deleteApps); err != nil { return } - if err := appDetailRepo.DeleteByAppIds(ctx, deleteAppIds); err != nil { + if err = appDetailRepo.DeleteByAppIds(ctx, deleteAppIds); err != nil { return } } - if err := appTagRepo.DeleteByAppIds(ctx, oldAppIds); err != nil { + if err = appTagRepo.DeleteByAppIds(ctx, oldAppIds); err != nil { return } - var () - for _, newApp := range newApps { if newApp.ID > 0 { for _, detail := range newApp.Details { @@ -551,31 +553,31 @@ func (a AppService) SyncAppListFromLocal() { } if len(newAppDetails) > 0 { - if err := appDetailRepo.BatchCreate(ctx, newAppDetails); err != nil { + if err = appDetailRepo.BatchCreate(ctx, newAppDetails); err != nil { return } } for _, updateAppDetail := range updateDetails { - if err := appDetailRepo.Update(ctx, updateAppDetail); err != nil { + if err = appDetailRepo.Update(ctx, updateAppDetail); err != nil { return } } if len(deleteAppDetails) > 0 { - if err := appDetailRepo.BatchDelete(ctx, deleteAppDetails); err != nil { + if err = appDetailRepo.BatchDelete(ctx, deleteAppDetails); err != nil { return } } if len(oldAppIds) > 0 { - if err := appTagRepo.DeleteByAppIds(ctx, oldAppIds); err != nil { + if err = appTagRepo.DeleteByAppIds(ctx, oldAppIds); err != nil { return } } if len(appTags) > 0 { - if err := appTagRepo.BatchCreate(ctx, appTags); err != nil { + if err = appTagRepo.BatchCreate(ctx, appTags); err != nil { return } } diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 86bbdb618..f96418798 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -664,11 +664,6 @@ func handleLocalAppDetail(versionDir string, appDetail *model.AppDetail) error { func handleLocalApp(appDir string) (app *model.App, err error) { fileOp := files.NewFileOp() - appDirEntries, err := os.ReadDir(appDir) - if err != nil || len(appDirEntries) == 0 { - err = errors.New("ErrAppDirNull") - return - } configYamlPath := path.Join(appDir, "data.yml") if !fileOp.Stat(configYamlPath) { err = errors.New(i18n.GetMsgWithMap("ErrFileNotFound", map[string]interface{}{"name": "data.yml"})) diff --git a/frontend/src/components/status/index.vue b/frontend/src/components/status/index.vue index 6788024fa..384d96c4e 100644 --- a/frontend/src/components/status/index.vue +++ b/frontend/src/components/status/index.vue @@ -27,6 +27,8 @@ const getType = (status: string) => { return 'success'; case 'stopped': return 'danger'; + case 'unhealthy': + return 'warning'; default: return ''; } diff --git a/frontend/src/views/app-store/installed/index.vue b/frontend/src/views/app-store/installed/index.vue index f56a52acf..4ef8c8b91 100644 --- a/frontend/src/views/app-store/installed/index.vue +++ b/frontend/src/views/app-store/installed/index.vue @@ -448,7 +448,7 @@ const openParam = (row: any) => { }; const isAppErr = (row: any) => { - return row.status.includes('Err') || row.status.includes('Error'); + return row.status.includes('Err') || row.status.includes('Error') || row.status.includes('UnHealthy'); }; const quickJump = () => {