set threshold for large files (#558)
Former-commit-id: 9b4aa87da78f2a9ad539e4229a5a1114a5716502 [formerly 0767dca86d42737c75bb7575015f9c29e35a55a2] [formerly 65887efb2d961d40c95374ac2336e76e53e3b4b0 [formerly 802bcd8cbd
]]
Former-commit-id: 3daab729620942ea0403f618588e731f90717e17 [formerly 5197f129ce4425a8716279e04f4e5b3653901c3d]
Former-commit-id: 0cb78fc0e87cb14ee540f2d3a2264d7b081c8985
pull/726/head
parent
694c750561
commit
8e4805ba69
|
@ -23,6 +23,10 @@ import (
|
|||
"github.com/maruel/natural"
|
||||
)
|
||||
|
||||
// The size of the loaded text can be rendered in the browser. Avoiding files that are too large causes browsers to crash.
|
||||
// Currently set to 10MB, 10 * 1024 * 1024 = 10485760 byte
|
||||
const textExtensionsRenderMaxSize int64 = 10485760
|
||||
|
||||
// File contains the information about a particular file or directory.
|
||||
type File struct {
|
||||
// Indicates the Kind of view on the front-end (Listing, editor or preview).
|
||||
|
@ -268,7 +272,7 @@ func (i *File) GetFileType(checkContent bool) error {
|
|||
|
||||
End:
|
||||
// If the file type is text, save its content.
|
||||
if i.Type == "text" {
|
||||
if i.Type == "text" && i.Size <= textExtensionsRenderMaxSize { // Avoiding files that are too large causes browsers to crash
|
||||
if len(content) == 0 {
|
||||
content, err = ioutil.ReadFile(i.Path)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue