diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java index 177cfe7527f..b16ea20526f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java @@ -385,7 +385,11 @@ public class RecoveryTarget extends AbstractComponent { InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); for (String existingFile : shard.store().directory().listAll()) { if (!request.snapshotFiles().contains(existingFile)) { - shard.store().directory().deleteFile(existingFile); + try { + shard.store().directory().deleteFile(existingFile); + } catch (IOException e) { + // ignore, we don't really care, will get deleted later on + } } } channel.sendResponse(VoidStreamable.INSTANCE); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java index 3bbf4b72b73..0849dc6b9df 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/store/support/AbstractStore.java @@ -179,6 +179,10 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen synchronized (mutex) { MapBuilder builder = MapBuilder.newMapBuilder(); for (String file : delegate.listAll()) { + if (file.endsWith(".md5")) { + // md5 are files we create, ignore them + continue; + } try { String md5 = preComputedMd5(file); @@ -233,6 +237,10 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen } @Override public void deleteFile(String name) throws IOException { + if (name.endsWith(".md5")) { + // ignore, this should not really happen... + return; + } delegate.deleteFile(name); try { delegate.deleteFile(name + ".md5");