diff --git a/gradle/changelog/lasy_loading.yaml b/gradle/changelog/lasy_loading.yaml new file mode 100644 index 0000000000..69373f4835 --- /dev/null +++ b/gradle/changelog/lasy_loading.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Lazy loading in the source view ([#2120](https://github.com/scm-manager/scm-manager/pull/2120)) diff --git a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java index d3e8669a7c..30b5a3f60f 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/BrowseCommandBuilder.java @@ -41,6 +41,7 @@ import sonia.scm.repository.spi.BrowseCommandRequest; import java.io.IOException; import java.io.Serializable; +import java.util.function.Supplier; //~--- JDK imports ------------------------------------------------------------ @@ -80,21 +81,23 @@ public final class BrowseCommandBuilder //~--- constructors --------------------------------------------------------- /** - * Constructs a new {@link LogCommandBuilder}, this constructor should + * Constructs a new {@link BrowseCommandBuilder}, this constructor should * only be called from the {@link RepositoryService}. * * @param cacheManager cache manager * @param browseCommand implementation of the {@link BrowseCommand} * @param repository repository to query - * @param preProcessorUtil + * @param preProcessorUtil this factory is used to create browse commands for the collapse feature */ BrowseCommandBuilder(CacheManager cacheManager, BrowseCommand browseCommand, - Repository repository, PreProcessorUtil preProcessorUtil) + Repository repository, PreProcessorUtil preProcessorUtil, + Supplier browseCommandFactory) { this.cache = cacheManager.getCache(CACHE_NAME); this.browseCommand = browseCommand; this.repository = repository; this.preProcessorUtil = preProcessorUtil; + this.browseCommandFactory = browseCommandFactory; } //~--- methods -------------------------------------------------------------- @@ -174,7 +177,7 @@ public final class BrowseCommandBuilder private BrowserResult computeBrowserResult() throws IOException { BrowserResult result = browseCommand.getBrowserResult(request); if (result != null && !request.isRecursive() && request.isCollapse()) { - new BrowserResultCollapser().collapseFolders(browseCommand, request, result.getFile()); + new BrowserResultCollapser().collapseFolders(browseCommandFactory.get(), request, result.getFile()); } return result; } @@ -457,6 +460,7 @@ public final class BrowseCommandBuilder /** Field description */ private final PreProcessorUtil preProcessorUtil; + private final Supplier browseCommandFactory; /** the repsitory */ private final Repository repository; diff --git a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java index d3b463a8bb..64ac0e541a 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/RepositoryService.java @@ -205,7 +205,7 @@ public final class RepositoryService implements Closeable { LOG.debug("create browse command for repository {}", repository); return new BrowseCommandBuilder(cacheManager, provider.getBrowseCommand(), - repository, preProcessorUtil); + repository, preProcessorUtil, provider::getBrowseCommand); } /**