@@ -19,29 +19,29 @@ import (
1919 "code.gitea.io/gitea/routers/api/v1/utils"
2020)
2121
22- func GetContentsListFromTrees (ctx context.Context , repo * repo_model.Repository , refCommit * utils.RefCommit , treeNames []string ) []* api.ContentsResponse {
22+ func GetContentsListFromTreePaths (ctx context.Context , repo * repo_model.Repository , refCommit * utils.RefCommit , treePaths []string ) []* api.ContentsResponse {
2323 var files []* api.ContentsResponse
2424 var size int64
25- for _ , file := range treeNames {
26- fileContents , _ := GetContents (ctx , repo , refCommit , file , false ) // ok if fails, then will be nil
27- if fileContents != nil && * fileContents .Content != "" {
25+ for _ , treePath := range treePaths {
26+ fileContents , _ := GetContents (ctx , repo , refCommit , treePath , false ) // ok if fails, then will be nil
27+ if fileContents != nil && fileContents . Content != nil && * fileContents .Content != "" {
2828 // if content isn't empty (e.g. due to the single blob being too large), add file size to response size
2929 // the content is base64 encoded, so it's size increases to around 4/3 of the original size
3030 size += fileContents .Size * 4 / 3
3131 }
3232 if size > setting .API .DefaultMaxResponseSize {
33- return files // return if max page size would be exceeded
33+ break // stop if max page size would be exceeded
3434 }
3535 files = append (files , fileContents )
3636 if len (files ) == setting .API .DefaultPagingNum {
37- return files // return if paging num or max size reached
37+ break // stop if paging num or max size reached
3838 }
3939 }
4040 return files
4141}
4242
4343func GetFilesResponseFromCommit (ctx context.Context , repo * repo_model.Repository , refCommit * utils.RefCommit , treeNames []string ) (* api.FilesResponse , error ) {
44- files := GetContentsListFromTrees (ctx , repo , refCommit , treeNames )
44+ files := GetContentsListFromTreePaths (ctx , repo , refCommit , treeNames )
4545 fileCommitResponse , _ := GetFileCommitResponse (repo , refCommit .Commit ) // ok if fails, then will be nil
4646 verification := GetPayloadCommitVerification (ctx , refCommit .Commit )
4747 filesResponse := & api.FilesResponse {
0 commit comments