Skip to content

Commit 9641b01

Browse files
committed
Fixes copyArchiveToContainerCmdImpl fail when hostResource has an empty dir which gets added as last entry to tar
CopyArchiveToContainerCmdImpl FAILS with com.github.dockerjava.api.exception.BadRequestException: Unable to perform tar on host resource /path/to/resource, if the resourceHost is a dir that containes an empty dir which will be added as the last entry to the generated .tar file.
1 parent 1ab6e63 commit 9641b01

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/main/java/com/github/dockerjava/core/util/TarDirWalker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public TarDirWalker(Path basePath, TarArchiveOutputStream tarArchiveOutputStream
2626
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
2727
if (!dir.equals(basePath)) {
2828
tarArchiveOutputStream.putArchiveEntry(new TarArchiveEntry(FilePathUtil.relativize(basePath, dir)));
29+
tarArchiveOutputStream.closeArchiveEntry();
2930
}
3031
return FileVisitResult.CONTINUE;
3132
}

0 commit comments

Comments
 (0)