mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 06:16:58 +00:00
add TestLFSSupport
This commit is contained in:
parent
7a7cbac171
commit
aa83b307db
2 changed files with 22 additions and 2 deletions
|
@ -27,6 +27,7 @@ type Client struct {
|
|||
contentTimeout time.Duration
|
||||
|
||||
followSymlinks bool
|
||||
supportLFS bool
|
||||
}
|
||||
|
||||
// TODO: once golang v1.19 is min requirement, we can switch to 'JoinPath()' of 'net/url' package
|
||||
|
@ -55,6 +56,7 @@ func NewClient(giteaRoot, giteaAPIToken string) (*Client, error) {
|
|||
fastClient: getFastHTTPClient(),
|
||||
|
||||
followSymlinks: true,
|
||||
supportLFS: true,
|
||||
}, err
|
||||
}
|
||||
|
||||
|
@ -67,8 +69,13 @@ func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource str
|
|||
}
|
||||
|
||||
func (client *Client) ServeRawContent(targetOwner, targetRepo, ref, resource string) (*fasthttp.Response, error) {
|
||||
url := joinURL(client.giteaRoot, giteaAPIRepos, targetOwner, targetRepo, "raw", resource+"?ref="+url.QueryEscape(ref))
|
||||
resp, err := client.do(client.contentTimeout, url)
|
||||
var apiURL string
|
||||
if client.supportLFS {
|
||||
apiURL = joinURL(client.giteaRoot, giteaAPIRepos, targetOwner, targetRepo, "media", resource+"?ref="+url.QueryEscape(ref))
|
||||
} else {
|
||||
apiURL = joinURL(client.giteaRoot, giteaAPIRepos, targetOwner, targetRepo, "raw", resource+"?ref="+url.QueryEscape(ref))
|
||||
}
|
||||
resp, err := client.do(client.contentTimeout, apiURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue