From cf78f5fda27c6aa303d9dfb3a066de65e9949b63 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 12 Nov 2022 00:32:32 +0100 Subject: [PATCH] format code --- server/gitea/client.go | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/server/gitea/client.go b/server/gitea/client.go index e77e26e..47280f0 100644 --- a/server/gitea/client.go +++ b/server/gitea/client.go @@ -151,25 +151,22 @@ func (client *Client) ServeRawContent(targetOwner, targetRepo, ref, resource str } } - // now we are sure it's content - { - // Set the MIME type - mimeType := client.getMimeTypeByExtension(resource) - resp.Response.Header.Set(ContentTypeHeader, mimeType) + // now we are sure it's content so set the MIME type + mimeType := client.getMimeTypeByExtension(resource) + resp.Response.Header.Set(ContentTypeHeader, mimeType) - if !shouldRespBeSavedToCache(resp.Response) { - return reader, resp.Response.Header, resp.StatusCode, err - } - - // now we write to cache and respond at the sime time - fileResp := FileResponse{ - Exists: true, - ETag: resp.Header.Get(ETagHeader), - MimeType: mimeType, - } - return fileResp.CreateCacheReader(reader, client.responseCache, cacheKey), resp.Response.Header, resp.StatusCode, nil + if !shouldRespBeSavedToCache(resp.Response) { + return reader, resp.Response.Header, resp.StatusCode, err } + // now we write to cache and respond at the sime time + fileResp := FileResponse{ + Exists: true, + ETag: resp.Header.Get(ETagHeader), + MimeType: mimeType, + } + return fileResp.CreateCacheReader(reader, client.responseCache, cacheKey), resp.Response.Header, resp.StatusCode, nil + case http.StatusNotFound: if err := client.responseCache.Set(cacheKey, FileResponse{ Exists: false,