Skip to content

Commit

Permalink
Core: don't listAll twice
Browse files Browse the repository at this point in the history
In elastic#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 elastic#9666
  • Loading branch information
mikemccand committed Feb 23, 2015
1 parent 8532715 commit 2ef8399
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -49,6 +49,13 @@ public DefaultFsDirectoryService(ShardId shardId, @IndexSettings Settings indexS

@Override
protected Directory newFSDirectory(File 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();
}
};
}
}

0 comments on commit 2ef8399

Please sign in to comment.