From ba00db990bca0bb4d05df6a66686ea488bb59e2d Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 12 Nov 2022 00:29:45 +0100 Subject: [PATCH] better code comment and move val into its own const --- server/gitea/client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/gitea/client.go b/server/gitea/client.go index 4ca3b90..e77e26e 100644 --- a/server/gitea/client.go +++ b/server/gitea/client.go @@ -29,6 +29,7 @@ const ( // pages server PagesCacheIndicatorHeader = "X-Pages-Cache" + symlinkReadLimit = 10000 // gitea giteaObjectTypeHeader = "X-Gitea-Object-Type" @@ -128,9 +129,9 @@ func (client *Client) ServeRawContent(targetOwner, targetRepo, ref, resource str objType := resp.Header.Get(giteaObjectTypeHeader) log.Trace().Msgf("server raw content object %q", objType) if client.followSymlinks && objType == objTypeSymlink { - // limit to 1000 chars defer reader.Close() - linkDestBytes, err := io.ReadAll(io.LimitReader(reader, 10000)) + // read limited chars for symlink + linkDestBytes, err := io.ReadAll(io.LimitReader(reader, symlinkReadLimit)) if err != nil { return nil, nil, http.StatusInternalServerError, err }