Avoid nilpointer on no File on Page

Fixes #5781
This commit is contained in:
Bjørn Erik Pedersen
2019-03-25 18:18:34 +01:00
parent 794d4052b8
commit 4dae52af68
15 changed files with 213 additions and 16 deletions

View File

@@ -53,6 +53,8 @@ type fileOverlap interface {
// Lang is the language code for this page. It will be the
// same as the site's language code.
Lang() string
IsZero() bool
}
type FileWithoutOverlap interface {
@@ -187,6 +189,10 @@ func (fi *FileInfo) Open() (hugio.ReadSeekCloser, error) {
return f, err
}
func (fi *FileInfo) IsZero() bool {
return fi == nil
}
// We create a lot of these FileInfo objects, but there are parts of it used only
// in some cases that is slightly expensive to construct.
func (fi *FileInfo) init() {