mirror of https://github.com/apache/lucene.git
LUCENE-7797: the static FSDirectory.listAll was always returning an empty array
This commit is contained in:
parent
3316f47bcf
commit
4cd83ea276
|
@ -97,6 +97,9 @@ Bug Fixes
|
|||
ArrayIndexOutOfBoundsException when byte blocks larger than 32 KB
|
||||
were added (Mike McCandless)
|
||||
|
||||
* LUCENE-7797: The static FSDirectory.listAll(Path) method was always
|
||||
returning an empty array. (Atkins Chang via Mike McCandless)
|
||||
|
||||
Improvements
|
||||
|
||||
* LUCENE-7782: OfflineSorter now passes the total number of items it
|
||||
|
|
|
@ -215,7 +215,7 @@ public abstract class FSDirectory extends BaseDirectory {
|
|||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
|
||||
for (Path path : stream) {
|
||||
String name = path.getFileName().toString();
|
||||
if (skipNames != null && skipNames.contains(name) == false) {
|
||||
if (skipNames == null || skipNames.contains(name) == false) {
|
||||
entries.add(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,9 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
||||
|
@ -137,5 +139,16 @@ public class TestDirectory extends LuceneTestCase {
|
|||
fsDir.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testListAll() throws Throwable {
|
||||
Path dir = createTempDir("testdir");
|
||||
Path file1 = Files.createFile(dir.resolve("tempfile1"));
|
||||
Path file2 = Files.createFile(dir.resolve("tempfile2"));
|
||||
Set<String> files = new HashSet<>(Arrays.asList(FSDirectory.listAll(dir)));
|
||||
|
||||
assertTrue(files.size() == 2);
|
||||
assertTrue(files.contains(file1.getFileName().toString()));
|
||||
assertTrue(files.contains(file2.getFileName().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue