Fixes copyArchiveToContainerCmdImpl fail when hostResource has an emtty dir which gets added as last entry to tar#574
Merged
marcuslinke merged 2 commits intodocker-java:masterfrom May 9, 2016
Conversation
…ty 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.
Contributor
|
@denlap007 Thanks for finding this. It would be nice to have a test case which reproduces exactly the scenario you described above. Would it be possible to add an appropriate test to |
Contributor
Author
|
Hi, I created a Test Case which reproduces the scenario described above. Shall I post it here or make a new pull request? |
Contributor
|
Its OK to add a new commit to this PR. Thanks. |
…pl when last tar entry is an empty dir
Current coverage is 23.80%
@@ master #574 diff @@
==========================================
Files 296 296
Lines 6129 6131 +2
Methods 0 0
Messages 0 0
Branches 532 533 +1
==========================================
Hits 1459 1459
- Misses 4585 4587 +2
Partials 85 85
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a simple fix for CopyArchiveToContainerCmdImpl which fails with com.github.dockerjava.api.exception.BadRequestException: Unable to perform tar on host resource /path/to/resource, when the resourceHost is a dir that contains an empty dir which will be added as the last entry to the generated .tar file.
Steps to reproduce
Name the dirs in the local dir exactly as shown above (preserve names a and b, the file name or content is irrelevant).
Then, the output will be:
com.github.dockerjava.api.exception.BadRequestException: Unable to perform tar on host resource /path/to/resourceIn oder to generate the tar file, all files under the local dir must be added to the tarArchiveOutputStream as tarArchiveEntries. The exception happens when the last entry added to the tarArchiveOutputStream is an empty dir.
Notice
In order to view the order with which the files and folders are added to the tarArchiveOutputStream you may add print messages to: com.github.dockerjava.core.util.TarDirWalker class. Specifically, to methods: preVisitDirectory(), visitFile(), e.g.
If in any case, the empty folder is not the last entry added to tarArchiveOutputStream the exception won't be reproduced.
This change is