Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

catch problems of file hash computation, see also: http://forum.yacy-websuche.de/viewtopic.php?p=15245#p15245

orbiter876746602d61
diff --git a/source/de/anomic/kelondro/blob/BLOBHeapModifier.java b/source/de/anomic/kelondro/blob/BLOBHeapModifier.java
index 4b8823f8d..df440512d 100644
--- a/source/de/anomic/kelondro/blob/BLOBHeapModifier.java
+++ b/source/de/anomic/kelondro/blob/BLOBHeapModifier.java
@@ -116,11 +116,17 @@ public class BLOBHeapModifier extends HeapReader implements BLOB {
try {
long start = System.currentTimeMillis();
String fingerprint = HeapWriter.fingerprintFileHash(this.heapFile);
- free.dump(HeapWriter.fingerprintGapFile(this.heapFile, fingerprint));
+ if (fingerprint == null) {
+ Log.logSevere("kelondroBLOBHeap", "cannot write a dump for " + heapFile.getName()+ ": fingerprint is null");
+ } else {
+ free.dump(HeapWriter.fingerprintGapFile(this.heapFile, fingerprint));
+ }
free.clear();
free = null;
- index.dump(HeapWriter.fingerprintIndexFile(this.heapFile, fingerprint));
- Log.logInfo("kelondroBLOBHeap", "wrote a dump for the " + this.index.size() + " index entries of " + heapFile.getName()+ " in " + (System.currentTimeMillis() - start) + " milliseconds.");
+ if (fingerprint != null) {
+ index.dump(HeapWriter.fingerprintIndexFile(this.heapFile, fingerprint));
+ Log.logInfo("kelondroBLOBHeap", "wrote a dump for the " + this.index.size() + " index entries of " + heapFile.getName()+ " in " + (System.currentTimeMillis() - start) + " milliseconds.");
+ }
index.close();
index = null;
} catch (IOException e) {
diff --git a/source/de/anomic/kelondro/blob/HeapReader.java b/source/de/anomic/kelondro/blob/HeapReader.java
index dc973c0c6..0b7613261 100644
--- a/source/de/anomic/kelondro/blob/HeapReader.java
+++ b/source/de/anomic/kelondro/blob/HeapReader.java
@@ -101,6 +101,10 @@ public class HeapReader {
// look for an index dump and read it if it exist
// if this is successfull, return true; otherwise false
String fingerprint = HeapWriter.fingerprintFileHash(this.heapFile);
+ if (fingerprint == null) {
+ Log.logSevere("HeapReader", "cannot generate a fingerprint for " + this.heapFile + ": null");
+ return false;
+ }
File fif = HeapWriter.fingerprintIndexFile(this.heapFile, fingerprint);
if (!fif.exists()) fif = new File(fif.getAbsolutePath() + ".gz");
File fgf = HeapWriter.fingerprintGapFile(this.heapFile, fingerprint);
diff --git a/source/de/anomic/kelondro/blob/HeapWriter.java b/source/de/anomic/kelondro/blob/HeapWriter.java
index 55c476743..756b66b72 100644
--- a/source/de/anomic/kelondro/blob/HeapWriter.java
+++ b/source/de/anomic/kelondro/blob/HeapWriter.java
@@ -120,6 +120,7 @@ public final class HeapWriter {
assert f.exists() : "file = " + f.toString();
String fp = Digest.fastFingerprintB64(f, false);
assert fp != null : "file = " + f.toString();
+ if (fp == null) return null;
return fp.substring(0, 12);
}
@@ -156,9 +157,13 @@ public final class HeapWriter {
try {
long start = System.currentTimeMillis();
String fingerprint = HeapWriter.fingerprintFileHash(this.heapFileREADY);
- new Gap().dump(fingerprintGapFile(this.heapFileREADY, fingerprint));
- index.dump(fingerprintIndexFile(this.heapFileREADY, fingerprint));
- Log.logInfo("kelondroBLOBHeapWriter", "wrote a dump for the " + this.index.size() + " index entries of " + heapFileREADY.getName()+ " in " + (System.currentTimeMillis() - start) + " milliseconds.");
+ if (fingerprint == null) {
+ Log.logSevere("kelondroBLOBHeapWriter", "cannot write a dump for " + heapFileREADY.getName()+ ": fingerprint is null");
+ } else {
+ new Gap().dump(fingerprintGapFile(this.heapFileREADY, fingerprint));
+ index.dump(fingerprintIndexFile(this.heapFileREADY, fingerprint));
+ Log.logInfo("kelondroBLOBHeapWriter", "wrote a dump for the " + this.index.size() + " index entries of " + heapFileREADY.getName()+ " in " + (System.currentTimeMillis() - start) + " milliseconds.");
+ }
index.close();
index = null;
} catch (IOException e) {
diff --git a/source/de/anomic/kelondro/order/Digest.java b/source/de/anomic/kelondro/order/Digest.java
index 4f9407dc9..987b3bc10 100644
--- a/source/de/anomic/kelondro/order/Digest.java
+++ b/source/de/anomic/kelondro/order/Digest.java
@@ -249,6 +249,7 @@ public class Digest {
try {
byte[] b = fastFingerprintRaw(file, includeDate);
assert b != null : "file = " + file.toString();
+ if (b == null || b.length == 0) return null;
assert b.length != 0 : "file = " + file.toString();
return Base64Order.enhancedCoder.encode(b);
} catch (IOException e) {