mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
Add github compatible tarball download API endpoints (#32572)
Fix #29654 Fix #32481 (cherry picked from commit 703be6bf307ed19ce8dc8cd311d24aeb6e5b9861) Conflicts: routers/api/v1/repo/file.go routers/web/repo/repo.go services/repository/archiver/archiver.go services/repository/archiver/archiver_test.go trivial context conflicts add missing function PathParam skipped in a very large refactor
This commit is contained in:
parent
3135e146f9
commit
3973f1022d
7 changed files with 152 additions and 31 deletions
|
@ -472,7 +472,12 @@ func RedirectDownload(ctx *context.Context) {
|
|||
// Download an archive of a repository
|
||||
func Download(ctx *context.Context) {
|
||||
uri := ctx.Params("*")
|
||||
aReq, err := archiver_service.NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri)
|
||||
ext, tp, err := archiver_service.ParseFileName(uri)
|
||||
if err != nil {
|
||||
ctx.ServerError("ParseFileName", err)
|
||||
return
|
||||
}
|
||||
aReq, err := archiver_service.NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, strings.TrimSuffix(uri, ext), tp)
|
||||
if err != nil {
|
||||
if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) {
|
||||
ctx.Error(http.StatusBadRequest, err.Error())
|
||||
|
@ -547,7 +552,12 @@ func download(ctx *context.Context, archiveName string, archiver *repo_model.Rep
|
|||
// kind of drop it on the floor if this is the case.
|
||||
func InitiateDownload(ctx *context.Context) {
|
||||
uri := ctx.Params("*")
|
||||
aReq, err := archiver_service.NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri)
|
||||
ext, tp, err := archiver_service.ParseFileName(uri)
|
||||
if err != nil {
|
||||
ctx.ServerError("ParseFileName", err)
|
||||
return
|
||||
}
|
||||
aReq, err := archiver_service.NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, strings.TrimSuffix(uri, ext), tp)
|
||||
if err != nil {
|
||||
ctx.ServerError("archiver_service.NewRequest", err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue