From 6867f4a3fad16eb9750cc791f870a23777e42d75 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Mon, 23 Feb 2015 04:12:03 -0500 Subject: [PATCH] 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 --- .../index/store/fs/DefaultFsDirectoryService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/index/store/fs/DefaultFsDirectoryService.java b/src/main/java/org/elasticsearch/index/store/fs/DefaultFsDirectoryService.java index 2f67e91ec1a..aedf668f167 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/DefaultFsDirectoryService.java +++ b/src/main/java/org/elasticsearch/index/store/fs/DefaultFsDirectoryService.java @@ -50,6 +50,13 @@ public class DefaultFsDirectoryService extends FsDirectoryService { @Override 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(); + } + }; } }