From 3a72fc95d9b7376e12676e93c7ec3735879b7c96 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:38:47 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E5=A4=84=E7=90=86=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=AD=A6=E5=91=8A=20(#6183)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +---- backend/app/service/app.go | 8 ++++---- backend/app/service/file.go | 4 ++-- backend/app/service/image.go | 4 ++-- backend/app/service/snapshot.go | 3 +++ backend/app/service/snapshot_recover.go | 4 ++-- backend/app/service/website.go | 4 +++- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 3fe440d57..a49bfc19f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,6 @@ build/1panel # Output of the go coverage tool, specifically when used with LiteIDE *.out -*_xpack.go # Dependency directories /pkg/ @@ -42,9 +41,7 @@ frontend/auto-imports.d.ts frontend/components.d.ts frontend/src/xpack backend/xpack -backend/router/entry_xpack.go -backend/server/init_xpack.go -backend/utils/xpack/xpack_xpack.go +*_xpack.go .history/ dist/ diff --git a/backend/app/service/app.go b/backend/app/service/app.go index a674be94f..191575ab4 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -91,10 +91,10 @@ func (a AppService) PageApp(req request.AppSearch) (interface{}, error) { } var appDTOs []*response.AppDto for _, ap := range apps { - ap.ReadMe = "" - ap.Website = "" - ap.Document = "" - ap.Github = "" + // ap.ReadMe = "" + // ap.Website = "" + // ap.Document = "" + // ap.Github = "" appDTO := &response.AppDto{ ID: ap.ID, Name: ap.Name, diff --git a/backend/app/service/file.go b/backend/app/service/file.go index ace3787eb..7ae96bedb 100644 --- a/backend/app/service/file.go +++ b/backend/app/service/file.go @@ -141,7 +141,7 @@ func shouldFilterPath(path string) bool { func (f *FileService) buildFileTree(node *response.FileTree, items []*files.FileInfo, op request.FileOption, level int) error { for _, v := range items { if shouldFilterPath(v.Path) { - global.LOG.Info("File Tree: Skipping %s due to filter\n", v.Path) + global.LOG.Infof("File Tree: Skipping %s due to filter\n", v.Path) continue } childNode := response.FileTree{ @@ -167,7 +167,7 @@ func (f *FileService) buildChildNode(childNode *response.FileTree, fileInfo *fil subInfo, err := files.NewFileInfo(op.FileOption) if err != nil { if os.IsPermission(err) || errors.Is(err, unix.EACCES) { - global.LOG.Info("File Tree: Skipping %s due to permission denied\n", fileInfo.Path) + global.LOG.Infof("File Tree: Skipping %s due to permission denied\n", fileInfo.Path) return nil } global.LOG.Errorf("File Tree: Skipping %s due to error: %s\n", fileInfo.Path, err.Error()) diff --git a/backend/app/service/image.go b/backend/app/service/image.go index 4a5190919..7c6e90570 100644 --- a/backend/app/service/image.go +++ b/backend/app/service/image.go @@ -286,7 +286,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) { if err != nil { return "", err } - authStr := base64.URLEncoding.EncodeToString(encodedJSON) + authStr := base64.StdEncoding.EncodeToString(encodedJSON) options.RegistryAuth = authStr } image := repo.DownloadUrl + "/" + req.ImageName @@ -295,7 +295,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) { out, err := client.ImagePull(context.TODO(), image, options) if err != nil { _, _ = file.WriteString("image pull failed!") - global.LOG.Errorf("image %s pull failed, err: %v", image, err) + _, _ = file.WriteString(fmt.Sprintf("image %s pull failed, err: %v", image, err)) return } defer out.Close() diff --git a/backend/app/service/snapshot.go b/backend/app/service/snapshot.go index 8d53201b2..07f14bfdd 100644 --- a/backend/app/service/snapshot.go +++ b/backend/app/service/snapshot.go @@ -48,6 +48,9 @@ func NewISnapshotService() ISnapshotService { func (u *SnapshotService) SearchWithPage(req dto.SearchWithPage) (int64, interface{}, error) { total, systemBackups, err := snapshotRepo.Page(req.Page, req.PageSize, commonRepo.WithLikeName(req.Info)) + if err != nil { + return 0, nil, err + } dtoSnap, err := loadSnapSize(systemBackups) if err != nil { return 0, nil, err diff --git a/backend/app/service/snapshot_recover.go b/backend/app/service/snapshot_recover.go index d559c0843..6b707340e 100644 --- a/backend/app/service/snapshot_recover.go +++ b/backend/app/service/snapshot_recover.go @@ -47,7 +47,7 @@ func (u *SnapshotService) HandleSnapshotRecover(snap model.Snapshot, isRecover b req.IsNew = true } if req.IsNew || snap.InterruptStep == "Backup" { - if err := backupBeforeRecover(snap, ""); err != nil { + if err := backupBeforeRecover(snap); err != nil { updateRecoverStatus(snap.ID, isRecover, "Backup", constant.StatusFailed, fmt.Sprintf("handle backup before recover failed, err: %v", err)) return } @@ -149,7 +149,7 @@ func (u *SnapshotService) HandleSnapshotRecover(snap model.Snapshot, isRecover b _, _ = cmd.Exec("systemctl daemon-reload && systemctl restart 1panel.service") } -func backupBeforeRecover(snap model.Snapshot, secret string) error { +func backupBeforeRecover(snap model.Snapshot) error { baseDir := fmt.Sprintf("%s/1panel_original/original_%s", global.CONF.System.BaseDir, snap.Name) var wg sync.WaitGroup var status model.SnapshotStatus diff --git a/backend/app/service/website.go b/backend/app/service/website.go index cb71cb9f4..e0738dfc8 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -475,7 +475,9 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error { tx, ctx := helper.GetTxAndContext() defer tx.Rollback() - go NewIBackupService().DeleteRecordByName("website", website.PrimaryDomain, website.Alias, req.DeleteBackup) + go func() { + _ = NewIBackupService().DeleteRecordByName("website", website.PrimaryDomain, website.Alias, req.DeleteBackup) + }() if err := websiteRepo.DeleteBy(ctx, commonRepo.WithByID(req.ID)); err != nil { return err }