diff --git a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java index 748813fb356ae..2ac5b491ff881 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -365,6 +365,13 @@ private static boolean upgradeLegacyNodeFolders(Logger logger, Settings settings SNAPSHOT_CACHE_FOLDER )); + final Set ignoredFileNames = new HashSet<>(Arrays.asList( + NODE_LOCK_FILENAME, + TEMP_FILE_NAME, + TEMP_FILE_NAME + ".tmp", + TEMP_FILE_NAME + ".final" + )); + try (DirectoryStream stream = Files.newDirectoryStream(legacyNodePath.path)) { for (Path subFolderPath : stream) { final String fileName = subFolderPath.getFileName().toString(); @@ -381,8 +388,7 @@ private static boolean upgradeLegacyNodeFolders(Logger logger, Settings settings targetSubFolderPath); } folderNames.add(fileName); - } else if (fileName.equals(NODE_LOCK_FILENAME) == false && - fileName.equals(TEMP_FILE_NAME) == false) { + } else if (ignoredFileNames.contains(fileName) == false) { throw new IllegalStateException("unexpected file/folder encountered during data folder upgrade: " + subFolderPath); }