diff --git a/server/gitea/cache.go b/server/gitea/cache.go index 8a2b06a..15504b7 100644 --- a/server/gitea/cache.go +++ b/server/gitea/cache.go @@ -100,11 +100,15 @@ type writeCacheReader struct { cache cache.ICache hasError bool doNotCache bool + complete bool } func (t *writeCacheReader) Read(p []byte) (n int, err error) { log.Trace().Msgf("[cache] read %q", t.cacheKey) n, err = t.originalReader.Read(p) + if err == io.EOF { + t.complete = true + } if err != nil && err != io.EOF { log.Trace().Err(err).Msgf("[cache] original reader for %q has returned an error", t.cacheKey) t.hasError = true @@ -120,7 +124,7 @@ func (t *writeCacheReader) Read(p []byte) (n int, err error) { } func (t *writeCacheReader) Close() error { - doWrite := !t.hasError && !t.doNotCache + doWrite := !t.hasError && !t.doNotCache && t.complete fc := *t.fileResponse fc.Body = t.buffer.Bytes() if doWrite {