aboutsummaryrefslogtreecommitdiffstats
path: root/repository
diff options
context:
space:
mode:
Diffstat (limited to 'repository')
-rw-r--r--repository/gogit.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/repository/gogit.go b/repository/gogit.go
index 248c34d5..d7c6823e 100644
--- a/repository/gogit.go
+++ b/repository/gogit.go
@@ -31,8 +31,13 @@ var _ ClockedRepo = &GoGitRepo{}
var _ TestedRepo = &GoGitRepo{}
type GoGitRepo struct {
- r *gogit.Repository
- path string
+ // Unfortunately, some parts of go-git are not thread-safe so we have to cover them with a big fat mutex here.
+ // See https://github.com/go-git/go-git/issues/48
+ // See https://github.com/go-git/go-git/issues/208
+ // See https://github.com/go-git/go-git/pull/186
+ rMutex sync.Mutex
+ r *gogit.Repository
+ path string
clocksMutex sync.Mutex
clocks map[string]lamport.Clock
@@ -335,7 +340,7 @@ func (repo *GoGitRepo) ClearBleveIndex(name string) error {
repo.indexesMutex.Lock()
defer repo.indexesMutex.Unlock()
- path := filepath.Join(repo.path, "indexes", name)
+ path := filepath.Join(repo.path, "git-bug", "indexes", name)
err := os.RemoveAll(path)
if err != nil {
@@ -448,6 +453,9 @@ func (repo *GoGitRepo) StoreData(data []byte) (Hash, error) {
// ReadData will attempt to read arbitrary data from the given hash
func (repo *GoGitRepo) ReadData(hash Hash) ([]byte, error) {
+ repo.rMutex.Lock()
+ defer repo.rMutex.Unlock()
+
obj, err := repo.r.BlobObject(plumbing.NewHash(hash.String()))
if err != nil {
return nil, err