HADOOP-7265. Keep track of relative paths in PathData. Contributed by Daryn Sharp
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1101132 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa4855e740
commit
a0391cddd3
|
@ -124,6 +124,9 @@ Trunk (unreleased changes)
|
|||
HADOOP-7251. Refactor the getmerge command to conform to new FsCommand
|
||||
class. (Daryn Sharp via szetszwo)
|
||||
|
||||
HADOOP-7265. Keep track of relative paths in PathData. (Daryn Sharp
|
||||
via szetszwo)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
|
|
@ -146,7 +146,11 @@ public class PathData {
|
|||
FileStatus[] stats = fs.listStatus(path);
|
||||
PathData[] items = new PathData[stats.length];
|
||||
for (int i=0; i < stats.length; i++) {
|
||||
items[i] = new PathData(fs, stats[i]);
|
||||
// preserve relative paths
|
||||
String basename = stats[i].getPath().getName();
|
||||
String parent = string;
|
||||
if (!parent.endsWith(Path.SEPARATOR)) parent += Path.SEPARATOR;
|
||||
items[i] = new PathData(fs, parent + basename, stats[i]);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,26 @@ public class TestPathData {
|
|||
checkPathData();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnqualifiedUriContents() throws Exception {
|
||||
dirString = "/tmp";
|
||||
item = new PathData(dirString, conf);
|
||||
PathData[] items = item.getDirectoryContents();
|
||||
for (PathData item : items) {
|
||||
assertTrue(item.toString().startsWith(dirString));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQualifiedUriContents() throws Exception {
|
||||
dirString = "file:/tmp";
|
||||
item = new PathData(dirString, conf);
|
||||
PathData[] items = item.getDirectoryContents();
|
||||
for (PathData item : items) {
|
||||
assertTrue(item.toString().startsWith(dirString));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithStringAndConfForBuggyPath() throws Exception {
|
||||
dirString = "file:///tmp";
|
||||
|
|
Loading…
Reference in New Issue