|
|
@ -287,22 +287,19 @@ func LFSFileGet(ctx *context.Context) { |
|
|
|
|
|
|
|
|
|
|
|
st := typesniffer.DetectContentType(buf) |
|
|
|
st := typesniffer.DetectContentType(buf) |
|
|
|
ctx.Data["IsTextFile"] = st.IsText() |
|
|
|
ctx.Data["IsTextFile"] = st.IsText() |
|
|
|
isRepresentableAsText := st.IsRepresentableAsText() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileSize := meta.Size |
|
|
|
|
|
|
|
ctx.Data["FileSize"] = meta.Size |
|
|
|
ctx.Data["FileSize"] = meta.Size |
|
|
|
ctx.Data["RawFileLink"] = fmt.Sprintf("%s%s/%s.git/info/lfs/objects/%s/%s", setting.AppURL, url.PathEscape(ctx.Repo.Repository.OwnerName), url.PathEscape(ctx.Repo.Repository.Name), url.PathEscape(meta.Oid), "direct") |
|
|
|
ctx.Data["RawFileLink"] = fmt.Sprintf("%s%s/%s.git/info/lfs/objects/%s/%s", setting.AppURL, url.PathEscape(ctx.Repo.Repository.OwnerName), url.PathEscape(ctx.Repo.Repository.Name), url.PathEscape(meta.Oid), "direct") |
|
|
|
switch { |
|
|
|
switch { |
|
|
|
case isRepresentableAsText: |
|
|
|
case st.IsRepresentableAsText(): |
|
|
|
if st.IsSvgImage() { |
|
|
|
if meta.Size >= setting.UI.MaxDisplayFileSize { |
|
|
|
ctx.Data["IsImageFile"] = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if fileSize >= setting.UI.MaxDisplayFileSize { |
|
|
|
|
|
|
|
ctx.Data["IsFileTooLarge"] = true |
|
|
|
ctx.Data["IsFileTooLarge"] = true |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if st.IsSvgImage() { |
|
|
|
|
|
|
|
ctx.Data["IsImageFile"] = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) |
|
|
|
rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) |
|
|
|
|
|
|
|
|
|
|
|
// Building code view blocks with line number on server side.
|
|
|
|
// Building code view blocks with line number on server side.
|
|
|
@ -338,6 +335,8 @@ func LFSFileGet(ctx *context.Context) { |
|
|
|
ctx.Data["IsAudioFile"] = true |
|
|
|
ctx.Data["IsAudioFile"] = true |
|
|
|
case st.IsImage() && (setting.UI.SVG.Enabled || !st.IsSvgImage()): |
|
|
|
case st.IsImage() && (setting.UI.SVG.Enabled || !st.IsSvgImage()): |
|
|
|
ctx.Data["IsImageFile"] = true |
|
|
|
ctx.Data["IsImageFile"] = true |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
// TODO: the logic is not the same as "renderFile" in "view.go"
|
|
|
|
} |
|
|
|
} |
|
|
|
ctx.HTML(http.StatusOK, tplSettingsLFSFile) |
|
|
|
ctx.HTML(http.StatusOK, tplSettingsLFSFile) |
|
|
|
} |
|
|
|
} |
|
|
|