mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-16 20:02:10 +00:00
tpl/os: remove 1mb limit for readFile.
This commit is contained in:
parent
32b86076ee
commit
ee9c136763
1 changed files with 0 additions and 12 deletions
12
tpl/os/os.go
12
tpl/os/os.go
|
@ -18,7 +18,6 @@ package os
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
_os "os"
|
_os "os"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/deps"
|
"github.com/gohugoio/hugo/deps"
|
||||||
|
@ -62,22 +61,11 @@ func (ns *Namespace) Getenv(key interface{}) (string, error) {
|
||||||
|
|
||||||
// readFile reads the file named by filename in the given filesystem
|
// readFile reads the file named by filename in the given filesystem
|
||||||
// and returns the contents as a string.
|
// and returns the contents as a string.
|
||||||
// There is a upper size limit set at 1 megabytes.
|
|
||||||
func readFile(fs afero.Fs, filename string) (string, error) {
|
func readFile(fs afero.Fs, filename string) (string, error) {
|
||||||
if filename == "" {
|
if filename == "" {
|
||||||
return "", errors.New("readFile needs a filename")
|
return "", errors.New("readFile needs a filename")
|
||||||
}
|
}
|
||||||
|
|
||||||
if info, err := fs.Stat(filename); err == nil {
|
|
||||||
if info.Size() > 1000000 {
|
|
||||||
return "", fmt.Errorf("file %q is too big", filename)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return "", fmt.Errorf("file %q does not exist", filename)
|
|
||||||
}
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
b, err := afero.ReadFile(fs, filename)
|
b, err := afero.ReadFile(fs, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in a new issue