1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

fix: 解决删除应用时 数据库状态错误导致脏数据的BUG

This commit is contained in:
zhengkunwang223 2023-03-10 16:22:48 +08:00 committed by zhengkunwang223
parent bb9c2490c4
commit b7ddb6fd42
3 changed files with 6 additions and 17 deletions

View File

@ -403,17 +403,6 @@ func (a AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, error
})
}
}
if app.Key == constant.AppMysql {
databases, _ := mysqlRepo.List()
for _, database := range databases {
res = append(res, dto.AppResource{
Type: "database",
Name: database.Name,
})
}
}
return res, nil
}

View File

@ -137,10 +137,10 @@ func deleteAppInstall(ctx context.Context, install model.AppInstall, deleteBacku
return err
}
}
if err := appInstallRepo.Delete(ctx, install); err != nil && !forceDelete {
if err := appInstallRepo.Delete(ctx, install); err != nil {
return err
}
if err := deleteLink(ctx, &install, deleteDB); err != nil && !forceDelete {
if err := deleteLink(ctx, &install, deleteDB, forceDelete); err != nil && !forceDelete {
return err
}
uploadDir := fmt.Sprintf("%s/1panel/uploads/app/%s/%s", global.CONF.System.BaseDir, install.App.Key, install.Name)
@ -163,7 +163,7 @@ func deleteAppInstall(ctx context.Context, install model.AppInstall, deleteBacku
return nil
}
func deleteLink(ctx context.Context, install *model.AppInstall, deleteDB bool) error {
func deleteLink(ctx context.Context, install *model.AppInstall, deleteDB bool, forceDelete bool) error {
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID))
if len(resources) == 0 {
return nil
@ -176,8 +176,9 @@ func deleteLink(ctx context.Context, install *model.AppInstall, deleteDB bool) e
continue
}
if err := mysqlService.Delete(ctx, dto.MysqlDBDelete{
ID: database.ID,
}); err != nil {
ID: database.ID,
ForceDelete: forceDelete,
}); err != nil && !forceDelete {
return err
}
}

View File

@ -41,7 +41,6 @@ func (f FileService) SearchUploadWithPage(req request.SearchUploadWithPage) (int
files []response.UploadInfo
backData []response.UploadInfo
)
_ = filepath.Walk(req.Path, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil