mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
fix cache
This commit is contained in:
parent
1438699b73
commit
de98ed5656
2 changed files with 8 additions and 1 deletions
|
@ -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">
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue