mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
next
This commit is contained in:
parent
14e2366f8e
commit
b2b22872a2
1 changed files with 3 additions and 13 deletions
|
@ -3,7 +3,6 @@
|
|||
package gitea
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -38,15 +37,7 @@ func NewClient(giteaRoot, giteaAPIToken string, fileResponseCache cache.SetGetKe
|
|||
}
|
||||
|
||||
func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource string) ([]byte, error) {
|
||||
// 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))
|
||||
// }
|
||||
// TODO: sdk client support media api!!!
|
||||
|
||||
rawBytes, resp, err := client.sdkClient.GetFile(targetOwner, targetRepo, ref, resource)
|
||||
rawBytes, resp, err := client.sdkClient.GetFile(targetOwner, targetRepo, ref, resource, client.supportLFS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -62,15 +53,14 @@ func (client *Client) GiteaRawContent(targetOwner, targetRepo, ref, resource str
|
|||
}
|
||||
|
||||
func (client *Client) ServeRawContent(targetOwner, targetRepo, ref, resource string) (io.ReadCloser, error) {
|
||||
// TODO: add func that return io.ReadCloser or io.ReadSeekCloser?
|
||||
rawBytes, resp, err := client.sdkClient.GetFile(targetOwner, targetRepo, ref, resource)
|
||||
reader, resp, err := client.sdkClient.GetFileReader(targetOwner, targetRepo, ref, resource, client.supportLFS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK:
|
||||
return io.NopCloser(bytes.NewReader(rawBytes)), nil
|
||||
return reader, nil
|
||||
case http.StatusNotFound:
|
||||
return nil, ErrorNotFound
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue