From de98ed56561be638c139634ac621f851cf558455 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 7 Nov 2022 23:43:20 +0100 Subject: [PATCH] fix cache --- html/error.html | 2 +- server/gitea/cache.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/html/error.html b/html/error.html index c84e12d..f1975f7 100644 --- a/html/error.html +++ b/html/error.html @@ -27,7 +27,7 @@
Sorry, but this page couldn't be served.
- We got an "%message%" error.
+ We got an "%message%"
We hope this isn't a problem on our end ;) - Make sure to check the troubleshooting section in the Docs!
diff --git a/server/gitea/cache.go b/server/gitea/cache.go index 5808b07..8de2cd2 100644 --- a/server/gitea/cache.go +++ b/server/gitea/cache.go @@ -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, } }