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

Changes LayerEntry#extractionPath to use AbsoluteUnixPath. #1014

Merged
merged 45 commits into from
Sep 20, 2018

Conversation

coollog
Copy link
Contributor

@coollog coollog commented Sep 19, 2018

Fixes #1009

@coollog coollog requested a review from a team September 19, 2018 22:36
@chanseokoh
Copy link
Member

chanseokoh commented Sep 20, 2018

Merge with master, and I should be able to look at this.

ImmutableList.builderWithExpectedSize(pathComponents.size() + relativePath.getNameCount());
newPathComponents.addAll(pathComponents);
for (Path pathComponent : relativePath) {
if (pathComponent.toString().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You needed this when parsing String directly, but I don't think it's needed here. For example, System.out.println(Paths.get("///a///a///a//").getNameCount()) return 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using this mostly for Paths.get(""), which would return a nameCount of 1, but also as a just-in-case since it's not guaranteed that name elements are not empty for different implementations of Path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, TIL about Paths.get("") having an empty filename.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, since resolving against a "" path doesn't add another name element, not having this in fromPath works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*having this in the call to fromPath in resolve(Path relativePath)

}
newPathComponents.add(pathComponent.toString());
}
return new AbsoluteUnixPath(newPathComponents.build());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If going for simplicity, I guess AbsoluteUnixPath.fromPath(Paths.get(unixPath).resolve(relativePath)) will work? The code of fromPath() is quite similar. (We still need to check that relativePath is not absolute.)

* @param relativePath the relative path to resolve against
* @return a new {@link AbsoluteUnixPath} representing the resolved path
*/
// TODO: Add test.
Copy link
Member

@chanseokoh chanseokoh Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add tests in this PR, unless you plan to add these methods in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I've already added tests and forgot to take this out.

@coollog coollog requested a review from a team September 20, 2018 17:43
@@ -177,7 +187,8 @@ public void testFilter_byNoEntries() throws CacheMetadataCorruptedException {

LayerEntry fakeLayerEntry =
new LayerEntry(
Paths.get("some/source/file", "some/source/directory"), Paths.get("extractionPath"));
Paths.get("some/source/file", "some/source/directory"),
Copy link
Member

@chanseokoh chanseokoh Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but this example seems weird, which just results in a path of /some/source/file/some/source/directory. Maybe the intention in the past was to pass two Paths as a list.

@coollog coollog merged commit 6dcda92 into master Sep 20, 2018
@coollog coollog deleted the extractionPath-AbsoluteUnixPath branch September 20, 2018 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants