aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-05-23 17:00:07 +0100
committerGitHub <noreply@github.com>2019-05-23 17:00:07 +0100
commit54bd63cd5c5645202625368c185b645c7771f687 (patch)
tree3857c5c770ffd5ec3e3cdaa910150a47fd2f579e /models
parent6eb53ac570ab9af51fc9cbd79f1db782edce57e0 (diff)
downloadgitea-54bd63cd5c5645202625368c185b645c7771f687.tar.gz
gitea-54bd63cd5c5645202625368c185b645c7771f687.zip
Change UpdateRepoIndex api to include watchers (#7012)
* Change UpdateRepoIndex api to include watchers * Add timeout
Diffstat (limited to 'models')
-rw-r--r--models/repo_indexer.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/models/repo_indexer.go b/models/repo_indexer.go
index 9a7daa0ff8..140ec66c03 100644
--- a/models/repo_indexer.go
+++ b/models/repo_indexer.go
@@ -57,8 +57,9 @@ func (repo *Repository) updateIndexerStatus(sha string) error {
}
type repoIndexerOperation struct {
- repo *Repository
- deleted bool
+ repo *Repository
+ deleted bool
+ watchers []chan<- error
}
var repoIndexerOperationQueue chan repoIndexerOperation
@@ -312,26 +313,30 @@ func nonGenesisChanges(repo *Repository, revision string) (*repoChanges, error)
func processRepoIndexerOperationQueue() {
for {
op := <-repoIndexerOperationQueue
+ var err error
if op.deleted {
- if err := indexer.DeleteRepoFromIndexer(op.repo.ID); err != nil {
+ if err = indexer.DeleteRepoFromIndexer(op.repo.ID); err != nil {
log.Error("DeleteRepoFromIndexer: %v", err)
}
} else {
- if err := updateRepoIndexer(op.repo); err != nil {
+ if err = updateRepoIndexer(op.repo); err != nil {
log.Error("updateRepoIndexer: %v", err)
}
}
+ for _, watcher := range op.watchers {
+ watcher <- err
+ }
}
}
// DeleteRepoFromIndexer remove all of a repository's entries from the indexer
-func DeleteRepoFromIndexer(repo *Repository) {
- addOperationToQueue(repoIndexerOperation{repo: repo, deleted: true})
+func DeleteRepoFromIndexer(repo *Repository, watchers ...chan<- error) {
+ addOperationToQueue(repoIndexerOperation{repo: repo, deleted: true, watchers: watchers})
}
// UpdateRepoIndexer update a repository's entries in the indexer
-func UpdateRepoIndexer(repo *Repository) {
- addOperationToQueue(repoIndexerOperation{repo: repo, deleted: false})
+func UpdateRepoIndexer(repo *Repository, watchers ...chan<- error) {
+ addOperationToQueue(repoIndexerOperation{repo: repo, deleted: false, watchers: watchers})
}
func addOperationToQueue(op repoIndexerOperation) {