mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	fix issue indexer not triggered when migrating a repository (#9332)
This commit is contained in:
		@@ -204,26 +204,31 @@ func populateIssueIndexer() {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for _, repo := range repos {
 | 
			
		||||
			is, err := models.Issues(&models.IssuesOptions{
 | 
			
		||||
				RepoIDs:  []int64{repo.ID},
 | 
			
		||||
				IsClosed: util.OptionalBoolNone,
 | 
			
		||||
				IsPull:   util.OptionalBoolNone,
 | 
			
		||||
			})
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				log.Error("Issues: %v", err)
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			if err = models.IssueList(is).LoadDiscussComments(); err != nil {
 | 
			
		||||
				log.Error("LoadComments: %v", err)
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			for _, issue := range is {
 | 
			
		||||
				UpdateIssueIndexer(issue)
 | 
			
		||||
			}
 | 
			
		||||
			UpdateRepoIndexer(repo)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpdateRepoIndexer add/update all issues of the repositories
 | 
			
		||||
func UpdateRepoIndexer(repo *models.Repository) {
 | 
			
		||||
	is, err := models.Issues(&models.IssuesOptions{
 | 
			
		||||
		RepoIDs:  []int64{repo.ID},
 | 
			
		||||
		IsClosed: util.OptionalBoolNone,
 | 
			
		||||
		IsPull:   util.OptionalBoolNone,
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Error("Issues: %v", err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	if err = models.IssueList(is).LoadDiscussComments(); err != nil {
 | 
			
		||||
		log.Error("LoadComments: %v", err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	for _, issue := range is {
 | 
			
		||||
		UpdateIssueIndexer(issue)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpdateIssueIndexer add/update an issue to the issue indexer
 | 
			
		||||
func UpdateIssueIndexer(issue *models.Issue) {
 | 
			
		||||
	var comments []string
 | 
			
		||||
 
 | 
			
		||||
@@ -111,6 +111,7 @@ func (r *indexerNotifier) NotifyDeleteRepository(doer *models.User, repo *models
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (r *indexerNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) {
 | 
			
		||||
	issue_indexer.UpdateRepoIndexer(repo)
 | 
			
		||||
	if setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty {
 | 
			
		||||
		code_indexer.UpdateRepoIndexer(repo)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user