Browse Source

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

pull/6185/head
ssongliu 3 months ago committed by GitHub
parent
commit
3a72fc95d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .gitignore
  2. 8
      backend/app/service/app.go
  3. 4
      backend/app/service/file.go
  4. 4
      backend/app/service/image.go
  5. 3
      backend/app/service/snapshot.go
  6. 4
      backend/app/service/snapshot_recover.go
  7. 4
      backend/app/service/website.go

5
.gitignore vendored

@ -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/

8
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,

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

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

3
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

4
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

4
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
}

Loading…
Cancel
Save