|
|
|
@ -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
|
|
|
|
|