diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.java index 272071d97..fdb3e20ae 100644 --- a/source/de/anomic/kelondro/kelondroTree.java +++ b/source/de/anomic/kelondro/kelondroTree.java @@ -50,7 +50,6 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.RandomAccessFile; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; diff --git a/source/de/anomic/plasma/plasmaWordIndexAssortment.java b/source/de/anomic/plasma/plasmaWordIndexAssortment.java index bf020242a..34c4cf9b4 100644 --- a/source/de/anomic/plasma/plasmaWordIndexAssortment.java +++ b/source/de/anomic/plasma/plasmaWordIndexAssortment.java @@ -210,7 +210,19 @@ public final class plasmaWordIndexAssortment { if (assortments != null) try { assortments.close(); } catch (IOException e) {} - if (!(assortmentFile.delete())) throw new RuntimeException("cannot delete assortment database"); + + try { + // make a back-up + File backupPath = new File(assortmentFile.getParentFile(), "ABKP"); + if (!(backupPath.exists())) backupPath.mkdirs(); + File backupFile = new File(backupPath, assortmentFile.getName() + System.currentTimeMillis()); + assortmentFile.renameTo(backupFile); + log.logInfo("a back-up of the deleted assortment file is in " + backupFile.toString()); + } catch (Exception e) { + // if this fails, delete the file + if (!(assortmentFile.delete())) throw new RuntimeException("cannot delete assortment database"); + } + if (assortmentFile.exists()) assortmentFile.delete(); assortments = new kelondroTree(assortmentFile, bufferSize, bufferStructure(assortmentLength), true); }