Skip to content
Snippets Groups Projects
Commit 2f35c7f8 authored by Nick Thomas's avatar Nick Thomas
Browse files

go-git has problems with concurrent use of git.Repo, so avoid it

parent 5d02dc60
No related branches found
No related tags found
1 merge request!1Initial implementation of an elasticsearch indexer in Go
Loading
Loading
@@ -2,7 +2,6 @@ package indexer
 
import (
"log"
"sync"
 
"srcd.works/go-git.v4/plumbing/object"
 
Loading
Loading
@@ -26,15 +25,11 @@ type Indexer struct {
// FIXME: none of the indexers worry about encoding right now
 
func (i *Indexer) SubmitCommit(c *object.Commit) error {
log.Print("Commit: ", c.Hash.String())
commit := BuildCommit(c, i.Submitter.ParentID())
return i.Submitter.Index(commit.ID, commit)
}
 
func (i *Indexer) SubmitBlob(f *object.File, _, toCommit *object.Commit) error {
log.Print("Write: ", f.Name)
// TODO(nick): Existing code doesn't index blobs > 10MiB in size
// FIXME(nick): Not sure commitSHA is right, or how it works at all
 
Loading
Loading
@@ -47,7 +42,6 @@ func (i *Indexer) SubmitBlob(f *object.File, _, toCommit *object.Commit) error {
}
 
func (i *Indexer) RemoveBlob(file *object.File, _, toCommit *object.Commit) error {
log.Print("Delete: ", file.Name)
blobID := GenerateBlobID(toCommit.Hash.String(), i.Submitter.ParentID())
 
return i.Submitter.Remove(blobID)
Loading
Loading
@@ -62,24 +56,15 @@ func (i *Indexer) IndexBlobs() error {
}
 
func (i *Indexer) Index() error {
wg := &sync.WaitGroup{}
wg.Add(2)
go func() {
if err := i.IndexBlobs(); err != nil {
log.Print("Error while indexing blobs:", err)
}
wg.Done()
}()
go func() {
if err := i.IndexCommits(); err != nil {
log.Print("Error while indexing commits:", err)
}
wg.Done()
}()
wg.Wait()
if err := i.IndexBlobs(); err != nil {
log.Print("Error while indexing blobs:", err)
return err
}
if err := i.IndexCommits(); err != nil {
log.Print("Error while indexing commits:", err)
return err
}
 
return i.Submitter.Flush()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment