From ae610d301ab5fc68e14b0e6934fc140e3bd5d3b4 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 12 Nov 2022 00:15:06 +0100 Subject: [PATCH] code format --- server/gitea/cache.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/gitea/cache.go b/server/gitea/cache.go index 19a7b1f..b1d66f3 100644 --- a/server/gitea/cache.go +++ b/server/gitea/cache.go @@ -60,7 +60,7 @@ func (f FileResponse) createHttpResponse(cacheKey string) (http.Header, int) { header.Set(ContentLengthHeader, fmt.Sprintf("%d", len(f.Body))) header.Set(PagesCacheIndicatorHeader, "true") - log.Trace().Msgf("fileCache for '%s' used", cacheKey) + log.Trace().Msgf("fileCache for %q used", cacheKey) return header, statusCode } @@ -95,19 +95,19 @@ func (t *writeCacheReader) Close() error { fc.Body = t.buff.Bytes() _ = t.cache.Set(t.cacheKey, fc, fileCacheTimeout) } - log.Trace().Msgf("cacheReader for '%s' saved=%v closed", t.cacheKey, !t.hasErr) + log.Trace().Msgf("cacheReader for %q saved=%t closed", t.cacheKey, !t.hasErr) return t.rc.Close() } 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 nil } + return &writeCacheReader{ rc: r, - buff: bytes.NewBuffer(buf), + buff: bytes.NewBuffer(make([]byte, 0)), f: &f, cache: cache, cacheKey: cacheKey,