Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/itzg/mc-image-helper?sort=semver)](https://github.com/itzg/mc-image-helper/releases/latest)
[![test](https://github.com/itzg/mc-image-helper/actions/workflows/test.yml/badge.svg)](https://github.com/itzg/mc-image-helper/actions/workflows/test.yml)
![LOC](https://img.shields.io/endpoint?url=https%3A%2F%2Fshields-codetab-code-loc-bridge.vercel.app%2Fapi%2Fcodeloc%3Fgithub%3Ditzg%2Fmc-image-helper%26language%3Djava)

This tool does the complicated bits for the [itzg/minecraft-server](https://github.com/itzg/docker-minecraft-server) and [itzg/bungeecord](https://github.com/itzg/docker-bungeecord/) Docker images.

Expand Down
17 changes: 11 additions & 6 deletions src/main/java/me/itzg/helpers/sync/SynchronizingFileVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ static int walkDirectories(List<Path> srcDest, boolean skipNewerInDestination,
final Path dest = srcDest.getLast();

for (final Path src : srcDest.subList(0, srcDest.size() - 1)) {
try {
Files.walkFileTree(src, new SynchronizingFileVisitor(src, dest, skipNewerInDestination, fileProcessor));
} catch (IOException e) {
log.error("Failed to sync and interpolate {} into {} : {}", src, dest, e.getMessage());
log.debug("Details", e);
return 1;
if (Files.isDirectory(src)) {
try {
Files.walkFileTree(src, new SynchronizingFileVisitor(src, dest, skipNewerInDestination, fileProcessor));
} catch (IOException e) {
log.error("Failed to sync and interpolate {} into {} : {}", src, dest, e.getMessage());
log.debug("Details", e);
return 1;
}
}
else {
log.debug("Skipping missing source directory {}", src);
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/test/java/me/itzg/helpers/sync/SyncAndInterpolateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ void copiesFromTwoSrcCommaDelim(Class<?> commandClass, @TempDir Path tempDir) th
assertThat(destDir.resolve("test4.txt")).exists();
}

@ParameterizedTest
@ValueSource(classes = {Sync.class, SyncAndInterpolate.class})
void skipsMissingSrcDir(Class<?> commandClass, @TempDir Path tempDir) throws Exception {
final Path srcDir1 = Files.createDirectory(tempDir.resolve("src"));
Files.createFile(srcDir1.resolve("test1.txt"));
Files.createFile(srcDir1.resolve("test2.txt"));
final Path destDir = Files.createDirectory(tempDir.resolve("dest"));

final String stderr = tapSystemErr(() -> {
final int exitCode = new CommandLine(commandClass)
.execute(
"--replace-env-file-suffixes=json",
String.join(",", srcDir1.toString(), tempDir.resolve("missing").toString()),
destDir.toString()
);

assertThat(exitCode).isEqualTo(0);
});
assertThat(stderr).isBlank();

assertThat(destDir).isNotEmptyDirectory();
assertThat(destDir.resolve("test1.txt")).exists();
assertThat(destDir.resolve("test2.txt")).exists();
}

}

}