diff options
author | 6543 <6543@obermui.de> | 2021-08-31 09:43:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-31 08:43:31 +0100 |
commit | d21702475ba43100d3a6e9505a1ae259e4842524 (patch) | |
tree | a9163f924f3a0eedda389a557759854312a8b9f0 /modules/git | |
parent | bb4cc876b1d0d5be5aa3fed7827ba3eac8f2ac18 (diff) | |
download | gitea-d21702475ba43100d3a6e9505a1ae259e4842524.tar.gz gitea-d21702475ba43100d3a6e9505a1ae259e4842524.zip |
Fix git.Blob.DataAsync(): close pipe since we return a NopCloser (#16899)
* make sure headGitRepo is closed on err too
* refactor
* Fix git.Blob.DataAsync(): exec cancel since we already read all bytes (close pipe since we return a NopCloser)
Diffstat (limited to 'modules/git')
-rw-r--r-- | modules/git/blob_nogogit.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/modules/git/blob_nogogit.go b/modules/git/blob_nogogit.go index 26815a63f1..3391bc3931 100644 --- a/modules/git/blob_nogogit.go +++ b/modules/git/blob_nogogit.go @@ -47,8 +47,8 @@ func (b *Blob) DataAsync() (io.ReadCloser, error) { if size < 4096 { bs, err := ioutil.ReadAll(io.LimitReader(rd, size)) + defer cancel() if err != nil { - cancel() return nil, err } _, err = rd.Discard(1) @@ -106,12 +106,12 @@ func (b *blobReader) Read(p []byte) (n int, err error) { // Close implements io.Closer func (b *blobReader) Close() error { + defer b.cancel() if b.n > 0 { for b.n > math.MaxInt32 { n, err := b.rd.Discard(math.MaxInt32) b.n -= int64(n) if err != nil { - b.cancel() return err } b.n -= math.MaxInt32 @@ -119,14 +119,12 @@ func (b *blobReader) Close() error { n, err := b.rd.Discard(int(b.n)) b.n -= int64(n) if err != nil { - b.cancel() return err } } if b.n == 0 { _, err := b.rd.Discard(1) b.n-- - b.cancel() return err } return nil |