resources/images: Make the image cache more robust

Also allow timeout to be set as a duration string, e.g. `30s`.

Fixes #6501
This commit is contained in:
Bjørn Erik Pedersen
2019-11-25 12:49:04 +01:00
parent 031f948f87
commit d6f7a9e28d
11 changed files with 85 additions and 32 deletions

View File

@@ -180,7 +180,7 @@ func newPageContentOutput(p *pageState) func(f output.Format) (*pageContentOutpu
needTimeout := !p.renderable || p.shortcodeState.hasShortcodes()
if needTimeout {
cp.initMain = parent.BranchdWithTimeout(p.s.siteCfg.timeout, func(ctx context.Context) (interface{}, error) {
cp.initMain = parent.BranchWithTimeout(p.s.siteCfg.timeout, func(ctx context.Context) (interface{}, error) {
return nil, initContent()
})
} else {
@@ -249,8 +249,10 @@ type pageContentOutput struct {
}
func (p *pageContentOutput) Content() (interface{}, error) {
p.p.s.initInit(p.initMain, p.p)
return p.content, nil
if p.p.s.initInit(p.initMain, p.p) {
return p.content, nil
}
return nil, nil
}
func (p *pageContentOutput) FuzzyWordCount() int {