]> source.dussan.org Git - gitea.git/commitdiff
Close the dataRC reader sooner (#16023)
authorzeripath <art27@cantab.net>
Sun, 30 May 2021 16:38:44 +0000 (17:38 +0100)
committerGitHub <noreply@github.com>
Sun, 30 May 2021 16:38:44 +0000 (17:38 +0100)
Fix #15932

Signed-off-by: Andrew Thornton <art27@cantab.net>
routers/repo/editor.go

index 2cc5c1e7f2fa1e6afc8b9c4f0264a123505de18c..2a2c56952d0866f75e9e6aaad0e5a393fc6c5f66 100644 (file)
@@ -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)