fix cache

This commit is contained in:
6543 2022-11-07 23:43:20 +01:00
parent 1438699b73
commit de98ed5656
No known key found for this signature in database
GPG key ID: B8BE6D610E61C862
2 changed files with 8 additions and 1 deletions

View file

@ -27,7 +27,7 @@
</h1>
<h5 class="text-center" style="max-width: 25em;">
Sorry, but this page couldn't be served.<br/>
We got an "%message%" error.<br/>
We got an <b>"%message%"</b><br/>
We hope this isn't a problem on our end ;) - Make sure to check the <a href="https://docs.codeberg.org/codeberg-pages/troubleshooting/" target="_blank">troubleshooting section in the Docs</a>!
</h5>
<small class="text-muted">

View file

@ -7,6 +7,8 @@ import (
"net/http"
"time"
"github.com/rs/zerolog/log"
"codeberg.org/codeberg/pages/server/cache"
)
@ -97,10 +99,15 @@ func (t *writeCacheReader) Close() error {
func (f FileResponse) CreateCacheReader(r io.ReadCloser, cache cache.SetGetKey, cacheKey string) io.ReadCloser {
buf := []byte{}
if r == nil || cache == nil || cacheKey == "" {
log.Error().Msg("could not create CacheReader")
return r
}
return &writeCacheReader{
rc: r,
buff: bytes.NewBuffer(buf),
f: &f,
cache: cache,
cacheKey: cacheKey,
}
}