Skip to content

Commit 553d46e

Browse files
KN4CK3Rwxiaoguang
andauthored
Do not double close reader (#29354)
Fixes #29346 --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent d3982bc commit 553d46e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

modules/git/blob_nogogit.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,17 @@ func (b *blobReader) Read(p []byte) (n int, err error) {
102102

103103
// Close implements io.Closer
104104
func (b *blobReader) Close() error {
105+
if b.rd == nil {
106+
return nil
107+
}
108+
105109
defer b.cancel()
106110

107-
return DiscardFull(b.rd, b.n+1)
111+
if err := DiscardFull(b.rd, b.n+1); err != nil {
112+
return err
113+
}
114+
115+
b.rd = nil
116+
117+
return nil
108118
}

routers/web/repo/editor.go

-3
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ func editFile(ctx *context.Context, isNewFile bool) {
161161
}
162162

163163
d, _ := io.ReadAll(dataRc)
164-
if err := dataRc.Close(); err != nil {
165-
log.Error("Error whilst closing blob data: %v", err)
166-
}
167164

168165
buf = append(buf, d...)
169166
if content, err := charset.ToUTF8(buf, charset.ConvertOpts{KeepBOM: true}); err != nil {

0 commit comments

Comments
 (0)