handle local md5 cases, don't include them in the list of files the directory has

This commit is contained in:
kimchy 2010-08-20 19:30:26 +03:00
parent b78597934f
commit 800e450e3a
2 changed files with 13 additions and 1 deletions

View File

@ -385,7 +385,11 @@ public class RecoveryTarget extends AbstractComponent {
InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id()); InternalIndexShard shard = (InternalIndexShard) indicesService.indexServiceSafe(request.shardId().index().name()).shardSafe(request.shardId().id());
for (String existingFile : shard.store().directory().listAll()) { for (String existingFile : shard.store().directory().listAll()) {
if (!request.snapshotFiles().contains(existingFile)) { if (!request.snapshotFiles().contains(existingFile)) {
try {
shard.store().directory().deleteFile(existingFile); shard.store().directory().deleteFile(existingFile);
} catch (IOException e) {
// ignore, we don't really care, will get deleted later on
}
} }
} }
channel.sendResponse(VoidStreamable.INSTANCE); channel.sendResponse(VoidStreamable.INSTANCE);

View File

@ -179,6 +179,10 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen
synchronized (mutex) { synchronized (mutex) {
MapBuilder<String, StoreFileMetaData> builder = MapBuilder.newMapBuilder(); MapBuilder<String, StoreFileMetaData> builder = MapBuilder.newMapBuilder();
for (String file : delegate.listAll()) { for (String file : delegate.listAll()) {
if (file.endsWith(".md5")) {
// md5 are files we create, ignore them
continue;
}
try { try {
String md5 = preComputedMd5(file); String md5 = preComputedMd5(file);
@ -233,6 +237,10 @@ public abstract class AbstractStore extends AbstractIndexShardComponent implemen
} }
@Override public void deleteFile(String name) throws IOException { @Override public void deleteFile(String name) throws IOException {
if (name.endsWith(".md5")) {
// ignore, this should not really happen...
return;
}
delegate.deleteFile(name); delegate.deleteFile(name);
try { try {
delegate.deleteFile(name + ".md5"); delegate.deleteFile(name + ".md5");