-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds entries for all directories in layer tarball. #891
Conversation
…erTools/jib into add-extraction-path-to-tar
* Holds a list of {@link TarArchiveEntry}s with unique extraction paths. The list also includes | ||
* all parent directories for each extraction path. | ||
*/ | ||
private static class UniqueTarArchiveEntries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use a LinkedHashMap
or something instead of making a custom data structure for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LinkedHashMap
would require creating a custom wrapper that uses the TarArchiveEntry#getName
as the hash object, which seemed more confusing than just having a custom data structure for storing a list of unique TarArchiveEntry
s
Path sourceFileRelativePath = sourceFile.getParent().relativize(path); | ||
for (Path sourceFileRelativePathComponent : sourceFileRelativePath) { | ||
subExtractionPath.append('/').append(sourceFileRelativePathComponent); | ||
subExtractionPath = subExtractionPath.resolve(sourceFileRelativePathComponent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't the point of using append('/')
instead of resolve
for forcing the paths to be Unix-style? (Comment on line 107)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that seems to be a relic of the old way - removing.
}); | ||
|
||
} else { | ||
TarArchiveEntry tarArchiveEntry = | ||
new TarArchiveEntry( | ||
sourceFile.toFile(), | ||
layerEntry.getExtractionPath() + "/" + sourceFile.getFileName()); | ||
Paths.get(layerEntry.getExtractionPath(), sourceFile.getFileName().toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could maybe be a bit more concise here with something like Paths.get(layerEntry.getExtractionPath()).resolve(sourceFile).toString()
? The multiple toString
s looks a bit confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'll actually break this out into another method to provide more readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, nevermind, it made it less readable.
Originally #772 , but reverted in #888 .
This one adds a fix for constructing the
TarArchiveEntry
extraction path correctly, whereas before it generated paths like/app/classes//com/test...
, which caused errors like #727 (comment). The main difference from #772 is inbuildAsTarArchiveEntries
.Fixes #523
Fixes #727