From 02f80130137279b6888285bef731961198fc6ce8 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 7 Nov 2005 14:57:37 +0000 Subject: [PATCH] auto-delete of corrupted word files during word-migration git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1047 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../anomic/plasma/plasmaWordIndexCache.java | 29 ++++++++++++------- source/yacy.java | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/source/de/anomic/plasma/plasmaWordIndexCache.java b/source/de/anomic/plasma/plasmaWordIndexCache.java index 8da039703..268afc3f9 100644 --- a/source/de/anomic/plasma/plasmaWordIndexCache.java +++ b/source/de/anomic/plasma/plasmaWordIndexCache.java @@ -574,18 +574,25 @@ public final class plasmaWordIndexCache implements plasmaWordIndexInterface { return -container.size(); } else { // the combined container will fit, read the container - Iterator entries = entity.elements(true); - plasmaWordIndexEntry entry; - while (entries.hasNext()) { - entry = (plasmaWordIndexEntry) entries.next(); - container.add(new plasmaWordIndexEntry[]{entry}, System.currentTimeMillis()); + try { + Iterator entries = entity.elements(true); + plasmaWordIndexEntry entry; + while (entries.hasNext()) { + entry = (plasmaWordIndexEntry) entries.next(); + container.add(new plasmaWordIndexEntry[]{entry}, System.currentTimeMillis()); + } + // we have read all elements, now delete the entity + entity.deleteComplete(); + entity.close(); entity = null; + // integrate the container into the assortments; this will work + assortmentCluster.storeTry(wordhash, container); + return size; + } catch (kelondroException e) { + // database corrupted, we simply give up the database and delete it + try {entity.close();} catch (Exception ee) {} entity = null; + try {db.delete();} catch (Exception ee) {} + return 0; } - // we have read all elements, now delete the entity - entity.deleteComplete(); - entity.close(); entity = null; - // integrate the container into the assortments; this will work - assortmentCluster.storeTry(wordhash, container); - return size; } } } finally { diff --git a/source/yacy.java b/source/yacy.java index 62fe195df..c9e3cc81f 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -663,7 +663,7 @@ public final class yacy { wordhash = wordfile.getName().substring(0, 12); migration = wordIndexCache.migrateWords2Assortment(wordhash); if (migration == 0) - log.logInfo("SKIPPED " + wordhash + ": too big"); + log.logInfo("SKIPPED " + wordhash + ": " + ((wordfile.exists()) ? "too big" : "database corrupted; deleted")); else if (migration > 0) log.logInfo("MIGRATED " + wordhash + ": " + migration + " entries"); else