From 800e450e3ac1aca74c75458e8e616b0b206a1ab8 Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 20 Aug 2010 19:30:26 +0300 Subject: [PATCH] handle local md5 cases, don't include them in the list of files the directory has --- .../index/shard/recovery/RecoveryTarget.java | 6 +++++- .../elasticsearch/index/store/support/AbstractStore.java | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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");