Skip to content

Commit

Permalink
Close the dataRC reader sooner (#16023)
Browse files Browse the repository at this point in the history
Fix #15932

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored May 30, 2021
1 parent effad26 commit 36dce0e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions routers/repo/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
ctx.NotFound("blob.Data", err)
return
}

defer dataRc.Close()

ctx.Data["FileSize"] = blob.Size()
Expand All @@ -122,6 +123,10 @@ func editFile(ctx *context.Context, isNewFile bool) {
}

d, _ := ioutil.ReadAll(dataRc)
if err := dataRc.Close(); err != nil {
log.Error("Error whilst closing blob data: %v", err)
}

buf = append(buf, d...)
if content, err := charset.ToUTF8WithErr(buf); err != nil {
log.Error("ToUTF8WithErr: %v", err)
Expand Down

0 comments on commit 36dce0e

Please sign in to comment.