fix: Fixed issue with database locked (#9898)

Refs https://github.com/1Panel-dev/1Panel/issues/9896
This commit is contained in:
CityFun
2025-08-07 17:30:37 +08:00
committed by GitHub
parent b3a55ea44d
commit 9fed5f4bb8
2 changed files with 4 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ type IAppTagRepo interface {
GetByAppId(appId uint) ([]model.AppTag, error)
GetByTagIds(tagIds []uint) ([]model.AppTag, error)
DeleteBy(ctx context.Context, opts ...DBOption) error
GetFirst(opts ...DBOption) (*model.AppTag, error)
GetFirst(ctx context.Context, opts ...DBOption) (*model.AppTag, error)
WithByTagID(tagID uint) DBOption
WithByAppID(appId uint) DBOption
@@ -71,9 +71,9 @@ func (a AppTagRepo) DeleteBy(ctx context.Context, opts ...DBOption) error {
return getTx(ctx, opts...).Delete(&model.AppTag{}).Error
}
func (a AppTagRepo) GetFirst(opts ...DBOption) (*model.AppTag, error) {
func (a AppTagRepo) GetFirst(ctx context.Context, opts ...DBOption) (*model.AppTag, error) {
var appTag model.AppTag
if err := getDb(opts...).First(&appTag).Error; err != nil {
if err := getTx(ctx, opts...).First(&appTag).Error; err != nil {
return nil, err
}
return &appTag, nil

View File

@@ -1074,7 +1074,7 @@ func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
for _, tag := range app.TagsKey {
tagId, ok := tagMap[tag]
if ok {
exist, _ := appTagRepo.GetFirst(appTagRepo.WithByTagID(tagId), appTagRepo.WithByAppID(app.ID))
exist, _ := appTagRepo.GetFirst(ctx, appTagRepo.WithByTagID(tagId), appTagRepo.WithByAppID(app.ID))
if exist != nil {
appTags = append(appTags, &model.AppTag{
AppId: app.ID,