Skip to content

Commit bc91c10

Browse files
fix: external helm app when linked to devtron and page breaks while adding project to it, without switching back to applist (#5443)
* checking if app exist for a app identifier, if yes then don't craete new installed app entry * nil check
1 parent 2f85352 commit bc91c10

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,17 @@ func (impl *InstalledAppDBServiceImpl) CreateNewAppEntryForAllInstalledApps(inst
372372
// Rollback tx on error.
373373
defer tx.Rollback()
374374
for _, installedApp := range installedApps {
375+
//check if for this unique identifier name an app already exists, if yes then continue
376+
appMetadata, err := impl.AppRepository.FindActiveByName(installedApp.GetUniqueAppNameIdentifier())
377+
if err != nil && !util.IsErrNoRows(err) {
378+
impl.Logger.Errorw("error in fetching app by unique app identifier", "appNameUniqueIdentifier", installedApp.GetUniqueAppNameIdentifier(), "err", err)
379+
return err
380+
}
381+
if appMetadata != nil && appMetadata.Id > 0 {
382+
//app already exists for this unique identifier hence not creating new app entry for this
383+
continue
384+
}
385+
375386
appModel := &app.App{
376387
Active: true,
377388
AppName: installedApp.GetUniqueAppNameIdentifier(),
@@ -381,7 +392,7 @@ func (impl *InstalledAppDBServiceImpl) CreateNewAppEntryForAllInstalledApps(inst
381392
DisplayName: installedApp.App.AppName,
382393
}
383394
appModel.CreateAuditLog(bean3.SystemUserId)
384-
err := impl.AppRepository.SaveWithTxn(appModel, tx)
395+
err = impl.AppRepository.SaveWithTxn(appModel, tx)
385396
if err != nil {
386397
impl.Logger.Errorw("error saving appModel", "err", err)
387398
return err

0 commit comments

Comments
 (0)