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> </h1>
<h5 class="text-center" style="max-width: 25em;"> <h5 class="text-center" style="max-width: 25em;">
Sorry, but this page couldn't be served.<br/> 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>! 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> </h5>
<small class="text-muted"> <small class="text-muted">

View File

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