mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
repository: workaround a non thread-safe path in go-git
fix https://github.com/MichaelMure/git-bug/issues/497
This commit is contained in:
parent
6d1c9346cc
commit
d000838cfb
@ -31,6 +31,11 @@ var _ ClockedRepo = &GoGitRepo{}
|
||||
var _ TestedRepo = &GoGitRepo{}
|
||||
|
||||
type GoGitRepo struct {
|
||||
// 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
|
||||
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user