Implement request limit for git

This commit is contained in:
Rene Pfeuffer
2020-02-18 08:22:36 +01:00
parent 8a1a43fcc5
commit f68423a5d8

View File

@@ -110,6 +110,8 @@ public class GitBrowseCommand extends AbstractGitCommand
private BrowserResult browserResult;
private int resultCount = 0;
public GitBrowseCommand(GitContext context, Repository repository, LfsBlobStoreFactory lfsBlobStoreFactory, SyncAsyncExecutor executor) {
super(context, repository);
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
@@ -251,7 +253,7 @@ public class GitBrowseCommand extends AbstractGitCommand
private FileObject findChildren(FileObject parent, org.eclipse.jgit.lib.Repository repo, BrowseCommandRequest request, ObjectId revId, TreeWalk treeWalk) throws IOException {
List<FileObject> files = Lists.newArrayList();
while (treeWalk.next())
while (treeWalk.next() && resultCount < request.getLimit())
{
FileObject fileObject = createFileObject(repo, request, revId, treeWalk);
@@ -262,6 +264,8 @@ public class GitBrowseCommand extends AbstractGitCommand
files.add(fileObject);
++resultCount;
if (request.isRecursive() && fileObject.isDirectory()) {
treeWalk.enterSubtree();
FileObject rc = findChildren(fileObject, repo, request, revId, treeWalk);