Fix DirCache,getEntriesWithin for empty string arguemnt
Change-Id: I0bea130df611de3ef8c9251093b11c62b5442cd1
This commit is contained in:
parent
19a366d532
commit
b4112c1748
|
@ -88,6 +88,13 @@ public void testEntriesWithin() throws Exception {
|
||||||
for (int i = aFirst, j = 0; i <= aLast; i++, j++)
|
for (int i = aFirst, j = 0; i <= aLast; i++, j++)
|
||||||
assertSame(ents[i], aContents[j]);
|
assertSame(ents[i], aContents[j]);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
final DirCacheEntry[] aContents = dc.getEntriesWithin("");
|
||||||
|
assertNotNull(aContents);
|
||||||
|
assertEquals(ents.length, aContents.length);
|
||||||
|
for (int i = 0; i < ents.length; i++)
|
||||||
|
assertSame(ents[i], aContents[i]);
|
||||||
|
}
|
||||||
|
|
||||||
assertNotNull(dc.getEntriesWithin("a."));
|
assertNotNull(dc.getEntriesWithin("a."));
|
||||||
assertEquals(0, dc.getEntriesWithin("a.").length);
|
assertEquals(0, dc.getEntriesWithin("a.").length);
|
||||||
|
|
|
@ -712,6 +712,11 @@ public DirCacheEntry getEntry(final String path) {
|
||||||
* @return all entries recursively contained within the subtree.
|
* @return all entries recursively contained within the subtree.
|
||||||
*/
|
*/
|
||||||
public DirCacheEntry[] getEntriesWithin(String path) {
|
public DirCacheEntry[] getEntriesWithin(String path) {
|
||||||
|
if (path.length() == 0) {
|
||||||
|
final DirCacheEntry[] r = new DirCacheEntry[sortedEntries.length];
|
||||||
|
System.arraycopy(sortedEntries, 0, r, 0, sortedEntries.length);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
if (!path.endsWith("/"))
|
if (!path.endsWith("/"))
|
||||||
path += "/";
|
path += "/";
|
||||||
final byte[] p = Constants.encode(path);
|
final byte[] p = Constants.encode(path);
|
||||||
|
|
Loading…
Reference in New Issue