From a42098f74564cdfed513ff47507c8e65d1cd8f5e Mon Sep 17 00:00:00 2001 From: jolheiser Date: Mon, 25 Apr 2022 23:08:04 -0500 Subject: [PATCH 1/2] Use router param for filepath Signed-off-by: jolheiser --- routers/api/v1/repo/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index ed51f6f4df2a2..f17febea8540c 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -62,7 +62,7 @@ func GetRawFile(ctx *context.APIContext) { return } - blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath) + blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Params("*")) if err != nil { if git.IsErrNotExist(err) { ctx.NotFound() From b9ea9436527a682f63e820cda5e6e4751df6cd2f Mon Sep 17 00:00:00 2001 From: jolheiser Date: Tue, 26 Apr 2022 10:10:45 -0500 Subject: [PATCH 2/2] Move TreePath back into RepoRefForAPI Signed-off-by: jolheiser --- modules/context/api.go | 1 + routers/api/v1/repo/file.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/context/api.go b/modules/context/api.go index 41d559f5b1c5f..7d281b998a7df 100644 --- a/modules/context/api.go +++ b/modules/context/api.go @@ -362,6 +362,7 @@ func RepoRefForAPI(next http.Handler) http.Handler { return } ctx.Repo.Commit = commit + ctx.Repo.TreePath = ctx.Params("*") return } diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index f17febea8540c..ed51f6f4df2a2 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -62,7 +62,7 @@ func GetRawFile(ctx *context.APIContext) { return } - blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Params("*")) + blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath) if err != nil { if git.IsErrNotExist(err) { ctx.NotFound()