From 832914bf6d95fc562eaf9d1b869d12e9b35b5d35 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 23 Sep 2010 19:13:48 +0200 Subject: [PATCH] create a mapbuilder when listing files and not ImmutableMap builder since it seems like listFiles might return duplicate files. --- .../common/blobstore/fs/AbstractFsBlobContainer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java index 9a0acb7b25d..b6b2c80c329 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/AbstractFsBlobContainer.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.blobstore.support.AbstractBlobContainer; import org.elasticsearch.common.blobstore.support.PlainBlobMetaData; import org.elasticsearch.common.collect.ImmutableMap; +import org.elasticsearch.common.collect.MapBuilder; import java.io.File; import java.io.FileInputStream; @@ -50,11 +51,13 @@ public abstract class AbstractFsBlobContainer extends AbstractBlobContainer { if (files == null || files.length == 0) { return ImmutableMap.of(); } - ImmutableMap.Builder builder = ImmutableMap.builder(); + MapBuilder builder = MapBuilder.newMapBuilder(); for (File file : files) { - builder.put(file.getName(), new PlainBlobMetaData(file.getName(), file.length())); + if (file.isFile()) { + builder.put(file.getName(), new PlainBlobMetaData(file.getName(), file.length())); + } } - return builder.build(); + return builder.immutableMap(); } public boolean deleteBlob(String blobName) throws IOException {