diff --git a/routers/repo/editor.go b/routers/repo/editor.go index 2cc5c1e7f2fa1..2a2c56952d086 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -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() @@ -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)