From 61502b33de61c48448162ed61935a14e2fa773aa Mon Sep 17 00:00:00 2001 From: theli Date: Thu, 13 Oct 2005 14:56:17 +0000 Subject: [PATCH] *) small modifications to importDB function - making it more failsafe - avoiding unnecessary exports of index word entries to string format and reimporting it afterwards git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@935 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/yacy.java | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/source/yacy.java b/source/yacy.java index 9b4831d05..675b7241a 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -695,9 +695,19 @@ public final class yacy { try { // Runtime rt = Runtime.getRuntime(); + String errorMsg = null; // configure destination DB File homeDBroot = new File(new File(homePath), "DATA/PLASMADB"); + if (!homeDBroot.exists()) errorMsg = "Home DB directory does not exist."; + if (!homeDBroot.canRead()) errorMsg = "Home DB directory is not readable."; + if (!homeDBroot.canWrite()) errorMsg = "Home DB directory is not writeable"; + if (!homeDBroot.isDirectory()) errorMsg = "Home DB Directory is not a directory."; + if (errorMsg != null) { + log.logSevere(errorMsg + "\nName: " + homeDBroot.getAbsolutePath()); + return; + } + if ((!homeDBroot.exists())&&(!homeDBroot.canRead())&&(!homeDBroot.isDirectory())) { log.logSevere("DB home directory can not be opened."); return; @@ -708,11 +718,17 @@ public final class yacy { homeUrlDB = new plasmaCrawlLURL(new File(homeDBroot, "urlHash.db"), 4*1024*1024); // configure import DB + errorMsg = null; File importDBroot = new File(importPath); - if ((!importDBroot.exists())&&(!importDBroot.canRead())&&(!importDBroot.isDirectory())) { - log.logSevere("DB import directory can not be opened."); + if (!importDBroot.exists()) errorMsg = "Import directory does not exist."; + if (!importDBroot.canRead()) errorMsg = "Import directory is not readable."; + if (!importDBroot.canWrite()) errorMsg = "Import directory is not writeable"; + if (!importDBroot.isDirectory()) errorMsg = "ImportDirectory is not a directory."; + if (errorMsg != null) { + log.logSevere(errorMsg + "\nName: " + homeDBroot.getAbsolutePath()); return; - } + } + log.logFine("Initializing source word index db."); importWordIndex = new plasmaWordIndex(importDBroot, 8*1024*1024, log); log.logFine("Initializing source URL db."); @@ -774,8 +790,7 @@ public final class yacy { } // adding word index entity to container - plasmaWordIndexEntry newEntry = new plasmaWordIndexEntry(importWordIdxEntry.toExternalForm()); - newContainer.add(newEntry,System.currentTimeMillis()); + newContainer.add(importWordIdxEntry,System.currentTimeMillis()); if (entryCounter % 500 == 0) { log.logFine(entryCounter + " word entries and " + wordCounter + " word entries processed so far.");