- fix for missing favicons in search widgets

- fix for bad digest/hash computation in case of interrupts to class

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7518 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 28c7615f24
commit dec4f36700

@ -75,7 +75,9 @@ public class yacysearchitem {
prop.put("references", "0");
prop.put("rssreferences", "0");
prop.put("dynamic", "0");
boolean isHtml = header.get(HeaderFramework.CONNECTION_PROP_PATH).endsWith(".html");
String p = header.get(HeaderFramework.CONNECTION_PROP_PATH);
boolean isHtml = p.endsWith(".html");
boolean isJson = p.endsWith(".json");
// find search event
final SearchEvent theSearch = SearchEventCache.getEvent(eventID);
@ -108,7 +110,7 @@ public class yacysearchitem {
DigestURI resultURL = result.url();
final int port = resultURL.getPort();
DigestURI faviconURL = null;
if (isHtml && !sb.isIntranetMode() && !resultURL.isLocal()) try {
if ((isHtml || isJson) && !sb.isIntranetMode() && !resultURL.isLocal()) try {
faviconURL = new DigestURI(resultURL.getProtocol() + "://" + resultURL.getHost() + ((port != -1) ? (":" + port) : "") + "/favicon.ico");
} catch (final MalformedURLException e1) {
Log.logException(e1);

@ -636,7 +636,12 @@ public class cryptbig {
if (s[0].equals("-md5")) {
// generate a public key from a password that can be used for encryption
if (s.length != 2) {help(); System.exit(-1);}
final String md5s = Digest.encodeMD5Hex(new File(s[1]));
String md5s = "";
try {
md5s = Digest.encodeMD5Hex(new File(s[1]));
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(md5s);
System.exit(0);
}

@ -102,7 +102,7 @@ public class Digest {
return encodeHex(encodeMD5Raw(key));
}
public static String encodeMD5Hex(final File file) {
public static String encodeMD5Hex(final File file) throws IOException {
// generate a hex representation from the md5 of a file
return encodeHex(encodeMD5Raw(file));
}
@ -145,7 +145,7 @@ public class Digest {
return result;
}
public static byte[] encodeMD5Raw(final File file) {
public static byte[] encodeMD5Raw(final File file) throws IOException {
FileInputStream in;
try {
in = new FileInputStream(file);
@ -166,15 +166,16 @@ public class Digest {
try {
while (true) {
c = md5consumer.nextFree();
if (c == null) throw new IOException("c == null, probably interrupted");
c.n = in.read(c.b);
if (c.n <= 0) break;
md5consumer.consume(c);
}
in.close();
} catch (final IOException e) {
System.out.println("file error with " + file.toString() + ": " + e.getMessage());
Log.logSevere("Digest", "file error with " + file.toString() + ": " + e.getMessage());
md5consumer.consume(md5FilechunkConsumer.poison);
return null;
throw e;
}
// put in poison into queue to tell the consumer to stop
md5consumer.consume(md5FilechunkConsumer.poison);
@ -184,10 +185,11 @@ public class Digest {
return md5result.get().digest();
} catch (InterruptedException e) {
Log.logException(e);
throw new IOException(e);
} catch (ExecutionException e) {
Log.logException(e);
throw new IOException(e);
}
return null;
}
private static class filechunk {
@ -228,12 +230,12 @@ public class Digest {
}
}
public filechunk nextFree() {
public filechunk nextFree() throws IOException {
try {
return empty.take();
} catch (InterruptedException e) {
Log.logException(e);
return null;
throw new IOException(e);
}
}
@ -357,7 +359,11 @@ public class Digest {
if (s[0].equals("-md5")) {
// generate a md5 from a given file
File f = new File(s[1]);
System.out.println("MD5 (" + f.getName() + ") = " + encodeMD5Hex(f));
try {
System.out.println("MD5 (" + f.getName() + ") = " + encodeMD5Hex(f));
} catch (IOException e) {
e.printStackTrace();
}
}
if (s[0].equals("-fhex")) {

Loading…
Cancel
Save