Reduce data races (#14549)
* Add race conditions into test * Fix Race in GetManager() * DataAsync() use error chan * just log no chan * finish
This commit is contained in:
parent
0d1444751f
commit
87009ab40a
3 changed files with 18 additions and 6 deletions
|
@ -11,6 +11,8 @@ import (
|
|||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
gitea_log "code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// Blob represents a Git object.
|
||||
|
@ -27,13 +29,13 @@ type Blob struct {
|
|||
// Calling the Close function on the result will discard all unread output.
|
||||
func (b *Blob) DataAsync() (io.ReadCloser, error) {
|
||||
stdoutReader, stdoutWriter := io.Pipe()
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
stderr := &strings.Builder{}
|
||||
err = NewCommand("cat-file", "--batch").RunInDirFullPipeline(b.repoPath, stdoutWriter, stderr, strings.NewReader(b.ID.String()+"\n"))
|
||||
err := NewCommand("cat-file", "--batch").RunInDirFullPipeline(b.repoPath, stdoutWriter, stderr, strings.NewReader(b.ID.String()+"\n"))
|
||||
if err != nil {
|
||||
err = ConcatenateError(err, stderr.String())
|
||||
gitea_log.Error("Blob.DataAsync Error: %v", err)
|
||||
_ = stdoutWriter.CloseWithError(err)
|
||||
} else {
|
||||
_ = stdoutWriter.Close()
|
||||
|
@ -50,8 +52,8 @@ func (b *Blob) DataAsync() (io.ReadCloser, error) {
|
|||
return &LimitedReaderCloser{
|
||||
R: bufReader,
|
||||
C: stdoutReader,
|
||||
N: int64(size),
|
||||
}, err
|
||||
N: size,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Size returns the uncompressed size of the blob
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue