diff options
Diffstat (limited to 'modules/indexer/code/bleve.go')
-rw-r--r-- | modules/indexer/code/bleve.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/indexer/code/bleve.go b/modules/indexer/code/bleve.go index 3a44a8dc05..64e974dc18 100644 --- a/modules/indexer/code/bleve.go +++ b/modules/indexer/code/bleve.go @@ -6,6 +6,7 @@ package code import ( "bufio" + "context" "fmt" "io" "os" @@ -180,7 +181,7 @@ func NewBleveIndexer(indexDir string) (*BleveIndexer, bool, error) { return indexer, created, err } -func (b *BleveIndexer) addUpdate(batchWriter git.WriteCloserError, batchReader *bufio.Reader, commitSha string, +func (b *BleveIndexer) addUpdate(ctx context.Context, batchWriter git.WriteCloserError, batchReader *bufio.Reader, commitSha string, update fileUpdate, repo *repo_model.Repository, batch *gitea_bleve.FlushingBatch) error { // Ignore vendored files in code search if setting.Indexer.ExcludeVendored && analyze.IsVendor(update.Filename) { @@ -190,7 +191,7 @@ func (b *BleveIndexer) addUpdate(batchWriter git.WriteCloserError, batchReader * size := update.Size if !update.Sized { - stdout, err := git.NewCommand("cat-file", "-s", update.BlobSha). + stdout, err := git.NewCommandContext(ctx, "cat-file", "-s", update.BlobSha). RunInDir(repo.RepoPath()) if err != nil { return err @@ -271,21 +272,21 @@ func (b *BleveIndexer) Close() { } // Index indexes the data -func (b *BleveIndexer) Index(repo *repo_model.Repository, sha string, changes *repoChanges) error { +func (b *BleveIndexer) Index(ctx context.Context, repo *repo_model.Repository, sha string, changes *repoChanges) error { batch := gitea_bleve.NewFlushingBatch(b.indexer, maxBatchSize) if len(changes.Updates) > 0 { // Now because of some insanity with git cat-file not immediately failing if not run in a valid git directory we need to run git rev-parse first! - if err := git.EnsureValidGitRepository(git.DefaultContext, repo.RepoPath()); err != nil { + if err := git.EnsureValidGitRepository(ctx, repo.RepoPath()); err != nil { log.Error("Unable to open git repo: %s for %-v: %v", repo.RepoPath(), repo, err) return err } - batchWriter, batchReader, cancel := git.CatFileBatch(git.DefaultContext, repo.RepoPath()) + batchWriter, batchReader, cancel := git.CatFileBatch(ctx, repo.RepoPath()) defer cancel() for _, update := range changes.Updates { - if err := b.addUpdate(batchWriter, batchReader, sha, update, repo, batch); err != nil { + if err := b.addUpdate(ctx, batchWriter, batchReader, sha, update, repo, batch); err != nil { return err } } |