mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-20 01:21:12 +08:00
fix: Fixed issue with database locked (#9898)
Refs https://github.com/1Panel-dev/1Panel/issues/9896
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user