aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/blob_nogogit.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-02-03 22:36:38 +0100
committerGitHub <noreply@github.com>2021-02-03 22:36:38 +0100
commit87009ab40a905b6f7d267f71434fda2a32725c57 (patch)
tree6a5d8ad96aa3f1457d70040395f25f30bc49121d /modules/git/blob_nogogit.go
parent0d1444751f755c624ffb4c56cb0020ce7a083c77 (diff)
downloadgitea-87009ab40a905b6f7d267f71434fda2a32725c57.tar.gz
gitea-87009ab40a905b6f7d267f71434fda2a32725c57.zip
Reduce data races (#14549)
* Add race conditions into test * Fix Race in GetManager() * DataAsync() use error chan * just log no chan * finish
Diffstat (limited to 'modules/git/blob_nogogit.go')
-rw-r--r--modules/git/blob_nogogit.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/modules/git/blob_nogogit.go b/modules/git/blob_nogogit.go
index 401b172860..731f7d06e8 100644
--- a/modules/git/blob_nogogit.go
+++ b/modules/git/blob_nogogit.go
@@ -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