2 files changed,
6 insertions(+),
8 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-03-03 19:29:41 +0200
Change ID:
pynkkrvzqszznskkpyxsttmoopqntutl
Parent:
0238022
jump to
| M | internal/git/tree.go |
| M | internal/handlers/repo.go |
M
internal/git/tree.go
@@ -73,17 +73,14 @@ }
type FileContent struct { IsBinary bool + IsImage bool Content []byte Mime string Size int64 } -func (fc FileContent) IsImage() bool { - return strings.HasPrefix(fc.Mime, "image/") -} - func (fc *FileContent) String() string { - if fc.IsBinary { + if fc.IsBinary || fc.IsImage { return "" } return string(fc.Content)@@ -130,6 +127,7 @@ }
return &FileContent{ IsBinary: isBin, + IsImage: strings.HasPrefix(mimeType, "image/"), Content: content, Mime: mimeType, Size: file.Size,
M
internal/handlers/repo.go
@@ -205,7 +205,7 @@
p := RepoFile{ Ref: ref, Path: treePath, - IsImage: fc.IsImage(), + IsImage: fc.IsImage, IsBinary: fc.IsBinary, Mime: fc.Mime, Size: fc.Size,@@ -217,7 +217,7 @@ h.write500(w, err)
return } - if !fc.IsImage() && !fc.IsBinary { + if !fc.IsImage && !fc.IsBinary { contentStr := fc.String() lc, err := countLines(strings.NewReader(contentStr)) if err != nil {@@ -470,7 +470,7 @@ if ferr != nil {
continue } - if fc.IsBinary { + if fc.IsBinary && fc.IsImage { continue }