Skip to content

Commit

Permalink
Improve memory usage in Commit.IsImageFile (go-gitea#95)
Browse files Browse the repository at this point in the history
Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>
  • Loading branch information
mrexodia authored and lafriks committed Nov 28, 2017
1 parent c2040d5 commit 6196634
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ func (c *Commit) IsImageFile(name string) bool {
return false
}

dataRc, err := blob.Data()
dataRc, err := blob.DataAsync()
if err != nil {
return false
}
defer dataRc.Close()
buf := make([]byte, 1024)
n, _ := dataRc.Read(buf)
buf = buf[:n]
Expand Down

0 comments on commit 6196634

Please sign in to comment.