Core: don't listAll twice

In #6636 we switched to a default FileSwitchDirectory that made
.listAll run twice on the same underlying file system directory.

This fixes listAll to do a single directory listing again.

Closes #9666
This commit is contained in:
Michael McCandless 2015-02-23 04:12:03 -05:00 committed by mikemccand
parent 98aad1bcbd
commit 6867f4a3fa
1 changed files with 8 additions and 1 deletions

View File

@ -50,6 +50,13 @@ public class DefaultFsDirectoryService extends FsDirectoryService {
@Override @Override
protected Directory newFSDirectory(Path location, LockFactory lockFactory) throws IOException { protected Directory newFSDirectory(Path location, LockFactory lockFactory) throws IOException {
return new FileSwitchDirectory(PRIMARY_EXTENSIONS, new MMapDirectory(location, lockFactory), new NIOFSDirectory(location, lockFactory), true); final MMapDirectory mmapDir = new MMapDirectory(location, lockFactory);
return new FileSwitchDirectory(PRIMARY_EXTENSIONS, mmapDir, new NIOFSDirectory(location, lockFactory), true) {
@Override
public String[] listAll() throws IOException {
// Avoid doing listAll twice:
return mmapDir.listAll();
}
};
} }
} }