Skip to content

Commit f542b68

Browse files
committed
reuse already existing copyDirectory()
1 parent 61dce4c commit f542b68

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexDatabaseTest.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -512,23 +512,6 @@ private void checkIndexDown(boolean historyBased, IndexDatabase idb) throws IOEx
512512
}
513513
}
514514

515-
private static void copyDirectory(Path src, Path dest) throws IOException {
516-
Files.walk(src).forEach(srcPath -> {
517-
try {
518-
Path destPath = dest.resolve(src.relativize(srcPath));
519-
if (Files.isDirectory(srcPath)) {
520-
if (!Files.exists(destPath)) {
521-
Files.createDirectory(destPath);
522-
}
523-
return;
524-
}
525-
Files.copy(srcPath, destPath);
526-
} catch (Exception e) {
527-
e.printStackTrace();
528-
}
529-
});
530-
}
531-
532515
/**
533516
* Make sure that history based reindex is not performed for projects
534517
* where some repositories are not instances of {@code RepositoryWithHistoryTraversal}
@@ -556,7 +539,7 @@ void testHistoryBasedReindexVsProjectWithDiverseRepos(boolean useCvs) throws Exc
556539
Path destinationPath = Path.of(repository.getSourceRoot(), projectName, subrepoName);
557540
Path sourcePath = Path.of(repository.getSourceRoot(), "cvs_test", "cvsrepo");
558541
assertTrue(sourcePath.toFile().exists());
559-
copyDirectory(sourcePath, destinationPath);
542+
repository.copyDirectory(sourcePath, destinationPath);
560543
assertTrue(destinationPath.toFile().exists());
561544

562545
Repository subRepo = RepositoryFactory.getRepository(destinationPath.toFile());

opengrok-indexer/src/test/java/org/opengrok/indexer/util/TestRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void create(@NotNull final URL url) throws IOException, URISyntaxExceptio
103103
}
104104
}
105105

106-
private void copyDirectory(Path src, Path dest) throws IOException {
106+
public void copyDirectory(Path src, Path dest) throws IOException {
107107
try (Stream<Path> stream = Files.walk(src)) {
108108
stream.forEach(sourceFile -> {
109109
if (sourceFile.equals(src)) {

0 commit comments

Comments
 (0)