mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-18 10:29:43 +00:00
Merge pull request 'Fix (half) empty cache issue' (#17) from bugfix/large-files-are-empty into main
Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/17
This commit is contained in:
commit
726d8321e8
1 changed files with 2 additions and 2 deletions
|
@ -418,7 +418,7 @@ func upstream(ctx *fasthttp.RequestCtx, targetOwner string, targetRepo string, t
|
||||||
var res *fasthttp.Response
|
var res *fasthttp.Response
|
||||||
var cachedResponse fileResponse
|
var cachedResponse fileResponse
|
||||||
var err error
|
var err error
|
||||||
if cachedValue, ok := fileResponseCache.Get(uri + "?timestamp=" + strconv.FormatInt(options.BranchTimestamp.Unix(), 10)); ok {
|
if cachedValue, ok := fileResponseCache.Get(uri + "?timestamp=" + strconv.FormatInt(options.BranchTimestamp.Unix(), 10)); ok && len(cachedValue.(fileResponse).body) > 0 {
|
||||||
cachedResponse = cachedValue.(fileResponse)
|
cachedResponse = cachedValue.(fileResponse)
|
||||||
} else {
|
} else {
|
||||||
req = fasthttp.AcquireRequest()
|
req = fasthttp.AcquireRequest()
|
||||||
|
@ -504,7 +504,7 @@ func upstream(ctx *fasthttp.RequestCtx, targetOwner string, targetRepo string, t
|
||||||
}
|
}
|
||||||
s.Step("response")
|
s.Step("response")
|
||||||
|
|
||||||
if res != nil {
|
if res != nil && ctx.Err() == nil {
|
||||||
cachedResponse.exists = true
|
cachedResponse.exists = true
|
||||||
cachedResponse.mimeType = mimeType
|
cachedResponse.mimeType = mimeType
|
||||||
cachedResponse.body = cacheBodyWriter.Bytes()
|
cachedResponse.body = cacheBodyWriter.Bytes()
|
||||||
|
|
Loading…
Reference in a new issue