Skip to content

Commit 3881828

Browse files
committed
Add error if file could not be retrieved
1 parent 4b231a3 commit 3881828

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

routers/api/v1/repo/file.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,12 @@ func GetFiles(ctx *context.APIContext) {
10491049

10501050
filesResponse, err := files_service.GetContentsListFromTrees(ctx, ctx.Repo.Repository, ref, files)
10511051
if err != nil {
1052-
ctx.APIError(http.StatusRequestEntityTooLarge, err.Error())
1052+
if err.Error() == "the combined size of the requested blobs exceeds the per-request limit set by the server administrator" {
1053+
ctx.APIError(http.StatusRequestEntityTooLarge, err.Error())
1054+
} else {
1055+
ctx.APIErrorNotFound("GetFiles")
1056+
}
1057+
return
10531058
}
10541059

10551060
ctx.SetTotalCountHeader(int64(count))

services/repository/files/file.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ func GetContentsListFromTrees(ctx context.Context, repo *repo_model.Repository,
2222
files := []*api.ContentsResponse{}
2323
var size int64 = 0
2424
for _, file := range treeNames {
25-
fileContents, _ := GetContents(ctx, repo, file, branch, false) // ok if fails, then will be nil
25+
fileContents, err := GetContents(ctx, repo, file, branch, false)
26+
if err != nil {
27+
return nil, err
28+
}
2629
if *fileContents.Content != "" {
2730
size += fileContents.Size // if content isn't empty (e. g. due to the single blob being too large), add file size to response size
2831
}

0 commit comments

Comments
 (0)