From 4ee6bc4fcac47edeea1f1e9fd5fbfd3ef595bbca Mon Sep 17 00:00:00 2001 From: slene Date: Sun, 25 May 2014 20:16:11 +0800 Subject: fix for new git api --- routers/repo/commit.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'routers/repo/commit.go') diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 44427b8a42..09dcaf5ead 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -85,11 +85,17 @@ func Diff(ctx *middleware.Context, params martini.Params) { return false } - data, err := blob.Data() + dataRc, err := blob.Data() if err != nil { return false } - _, isImage := base.IsImageFile(data) + buf := make([]byte, 1024) + n, _ := dataRc.Read(buf) + if n > 0 { + buf = buf[:n] + } + dataRc.Close() + _, isImage := base.IsImageFile(buf) return isImage } -- cgit v1.2.3