style: 处理代码警告 (#6183)

pull/6185/head
ssongliu 3 months ago committed by GitHub
parent 64405fba3d
commit 3a72fc95d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

5
.gitignore vendored

@ -29,7 +29,6 @@ build/1panel
# Output of the go coverage tool, specifically when used with LiteIDE # Output of the go coverage tool, specifically when used with LiteIDE
*.out *.out
*_xpack.go
# Dependency directories # Dependency directories
/pkg/ /pkg/
@ -42,9 +41,7 @@ frontend/auto-imports.d.ts
frontend/components.d.ts frontend/components.d.ts
frontend/src/xpack frontend/src/xpack
backend/xpack backend/xpack
backend/router/entry_xpack.go *_xpack.go
backend/server/init_xpack.go
backend/utils/xpack/xpack_xpack.go
.history/ .history/
dist/ dist/

@ -91,10 +91,10 @@ func (a AppService) PageApp(req request.AppSearch) (interface{}, error) {
} }
var appDTOs []*response.AppDto var appDTOs []*response.AppDto
for _, ap := range apps { for _, ap := range apps {
ap.ReadMe = "" // ap.ReadMe = ""
ap.Website = "" // ap.Website = ""
ap.Document = "" // ap.Document = ""
ap.Github = "" // ap.Github = ""
appDTO := &response.AppDto{ appDTO := &response.AppDto{
ID: ap.ID, ID: ap.ID,
Name: ap.Name, Name: ap.Name,

@ -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 { func (f *FileService) buildFileTree(node *response.FileTree, items []*files.FileInfo, op request.FileOption, level int) error {
for _, v := range items { for _, v := range items {
if shouldFilterPath(v.Path) { 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 continue
} }
childNode := response.FileTree{ childNode := response.FileTree{
@ -167,7 +167,7 @@ func (f *FileService) buildChildNode(childNode *response.FileTree, fileInfo *fil
subInfo, err := files.NewFileInfo(op.FileOption) subInfo, err := files.NewFileInfo(op.FileOption)
if err != nil { if err != nil {
if os.IsPermission(err) || errors.Is(err, unix.EACCES) { 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 return nil
} }
global.LOG.Errorf("File Tree: Skipping %s due to error: %s\n", fileInfo.Path, err.Error()) global.LOG.Errorf("File Tree: Skipping %s due to error: %s\n", fileInfo.Path, err.Error())

@ -286,7 +286,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
authStr := base64.URLEncoding.EncodeToString(encodedJSON) authStr := base64.StdEncoding.EncodeToString(encodedJSON)
options.RegistryAuth = authStr options.RegistryAuth = authStr
} }
image := repo.DownloadUrl + "/" + req.ImageName 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) out, err := client.ImagePull(context.TODO(), image, options)
if err != nil { if err != nil {
_, _ = file.WriteString("image pull failed!") _, _ = 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 return
} }
defer out.Close() defer out.Close()

@ -48,6 +48,9 @@ func NewISnapshotService() ISnapshotService {
func (u *SnapshotService) SearchWithPage(req dto.SearchWithPage) (int64, interface{}, error) { func (u *SnapshotService) SearchWithPage(req dto.SearchWithPage) (int64, interface{}, error) {
total, systemBackups, err := snapshotRepo.Page(req.Page, req.PageSize, commonRepo.WithLikeName(req.Info)) total, systemBackups, err := snapshotRepo.Page(req.Page, req.PageSize, commonRepo.WithLikeName(req.Info))
if err != nil {
return 0, nil, err
}
dtoSnap, err := loadSnapSize(systemBackups) dtoSnap, err := loadSnapSize(systemBackups)
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err

@ -47,7 +47,7 @@ func (u *SnapshotService) HandleSnapshotRecover(snap model.Snapshot, isRecover b
req.IsNew = true req.IsNew = true
} }
if req.IsNew || snap.InterruptStep == "Backup" { 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)) updateRecoverStatus(snap.ID, isRecover, "Backup", constant.StatusFailed, fmt.Sprintf("handle backup before recover failed, err: %v", err))
return return
} }
@ -149,7 +149,7 @@ func (u *SnapshotService) HandleSnapshotRecover(snap model.Snapshot, isRecover b
_, _ = cmd.Exec("systemctl daemon-reload && systemctl restart 1panel.service") _, _ = 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) baseDir := fmt.Sprintf("%s/1panel_original/original_%s", global.CONF.System.BaseDir, snap.Name)
var wg sync.WaitGroup var wg sync.WaitGroup
var status model.SnapshotStatus var status model.SnapshotStatus

@ -475,7 +475,9 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error {
tx, ctx := helper.GetTxAndContext() tx, ctx := helper.GetTxAndContext()
defer tx.Rollback() 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 { if err := websiteRepo.DeleteBy(ctx, commonRepo.WithByID(req.ID)); err != nil {
return err return err
} }

Loading…
Cancel
Save