From bb2095fe39ec4a57560d13cf83c470814a4df1f6 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sun, 22 Jan 2006 01:03:01 +0000 Subject: [PATCH] assortment files are now not deleted, but shifted to a backup directory. See also: http://www.yacy-forum.de/viewtopic.php?p=15458#15458 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1394 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/kelondro/kelondroTree.java | 1 - .../anomic/plasma/plasmaWordIndexAssortment.java | 14 +++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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); }