Skip to content
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

Merged
merged 30 commits into from
Aug 29, 2018

Conversation

coollog
Copy link
Contributor

@coollog coollog commented Aug 28, 2018

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 in buildAsTarArchiveEntries.

Fixes #523
Fixes #727

@coollog coollog requested a review from a team August 28, 2018 18:56
* 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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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 TarArchiveEntrys

Path sourceFileRelativePath = sourceFile.getParent().relativize(path);
for (Path sourceFileRelativePathComponent : sourceFileRelativePath) {
subExtractionPath.append('/').append(sourceFileRelativePathComponent);
subExtractionPath = subExtractionPath.resolve(sourceFileRelativePathComponent);
Copy link
Contributor

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)

Copy link
Contributor Author

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.

@coollog coollog requested a review from a team August 29, 2018 14:06
@coollog coollog added this to the v0.9.10 milestone Aug 29, 2018
});

} else {
TarArchiveEntry tarArchiveEntry =
new TarArchiveEntry(
sourceFile.toFile(),
layerEntry.getExtractionPath() + "/" + sourceFile.getFileName());
Paths.get(layerEntry.getExtractionPath(), sourceFile.getFileName().toString())
Copy link
Contributor

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 toStrings looks a bit confusing.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants