From 8b89c46afe5bb52d60e2441d896ddc89333c76d7 Mon Sep 17 00:00:00 2001 From: orbiter Date: Fri, 8 Jul 2005 16:06:35 +0000 Subject: [PATCH] fixed problem with cache write git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@394 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../de/anomic/plasma/plasmaCrawlWorker.java | 4 +- .../de/anomic/plasma/plasmaSwitchboard.java | 46 +++++++------------ 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/source/de/anomic/plasma/plasmaCrawlWorker.java b/source/de/anomic/plasma/plasmaCrawlWorker.java index e65a4f50c..3596d614e 100644 --- a/source/de/anomic/plasma/plasmaCrawlWorker.java +++ b/source/de/anomic/plasma/plasmaCrawlWorker.java @@ -335,7 +335,9 @@ public final class plasmaCrawlWorker extends Thread { FileOutputStream fos = null; try { fos = new FileOutputStream(cacheFile); - htCache.cacheArray = res.writeContent(fos); // writes in cacheArray and cache file + res.writeContent(fos); // superfluous write to array + htCache.cacheArray = null; + //htCache.cacheArray = res.writeContent(fos); // writes in cacheArray and cache file } finally { if (fos!=null)try{fos.close();}catch(Exception e){} } diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 90c898e17..36ddd6860 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -458,42 +458,27 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser if (entry == null) return false; // store response header - if ((entry.status == plasmaHTCache.CACHE_FILL) || - (entry.status == plasmaHTCache.CACHE_STALE_RELOAD_GOOD) || - (entry.status == plasmaHTCache.CACHE_STALE_RELOAD_BAD)) { + if (entry.responseHeader != null) { cacheManager.storeHeader(entry.nomalizedURLHash, entry.responseHeader); + log.logInfo("WROTE HEADER for " + entry.cacheFile); } - // work off unwritten files and undone parsing - String storeError = null; - if (((entry.status == plasmaHTCache.CACHE_FILL) || (entry.status == plasmaHTCache.CACHE_STALE_RELOAD_GOOD)) && - ((storeError = entry.shallStoreCache()) == null)) { - - // write file if not written yet - if (entry.cacheArray != null) { - cacheManager.writeFile(entry.url, entry.cacheArray); - log.logInfo("WRITE FILE (" + entry.cacheArray.length + " bytes) " + entry.cacheFile); - } - // enqueue for further crawling - enQueue(sbQueue.newEntry(entry.url, plasmaURL.urlHash(entry.referrerURL()), - entry.requestHeader.ifModifiedSince(), entry.requestHeader.containsKey(httpHeader.COOKIE), - entry.initiator(), entry.depth, entry.profile.handle(), - entry.name() - )); - } else if (entry.status == plasmaHTCache.CACHE_PASSING) { - // even if the file should not be stored in the cache, it can be used to be indexed - if (storeError != null) log.logDebug("NOT STORED " + entry.cacheFile + ":" + storeError); - - // enqueue for further crawling - enQueue(sbQueue.newEntry(entry.url, plasmaURL.urlHash(entry.referrerURL()), - entry.requestHeader.ifModifiedSince(), entry.requestHeader.containsKey(httpHeader.COOKIE), - entry.initiator(), entry.depth, entry.profile.handle(), - entry.name() - )); + // work off unwritten files + if (entry.cacheArray != null) { + cacheManager.writeFile(entry.url, entry.cacheArray); + log.logInfo("WROTE FILE (" + entry.cacheArray.length + " bytes) for " + entry.cacheFile); } + + // enqueue for further crawling + enQueue(sbQueue.newEntry(entry.url, plasmaURL.urlHash(entry.referrerURL()), + entry.requestHeader.ifModifiedSince(), entry.requestHeader.containsKey(httpHeader.COOKIE), + entry.initiator(), entry.depth, entry.profile.handle(), + entry.name() + )); // write log - + + /* switch (entry.status) { case plasmaHTCache.CACHE_UNFILLED: log.logInfo("CACHE UNFILLED: " + entry.cacheFile); break; @@ -513,6 +498,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser default: log.logInfo("CACHE STATE UNKNOWN: " + entry.cacheFile); break; } + */ return true; }