mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
enhanced image search result display: concurrent loading of images before they are displayed
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7109 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
72a096fccb
commit
ae07e11bc5
|
@ -173,6 +173,7 @@ public class yacysearchitem {
|
|||
if (ms == null) {
|
||||
prop.put("content_item", "0");
|
||||
} else {
|
||||
sb.loader.loadIfNotExistBackground(ms.href.toNormalform(true, false), 1024 * 1024 * 10);
|
||||
prop.putHTML("content_item_hrefCache", (auth) ? "/ViewImage.png?url=" + ms.href.toNormalform(true, false) : ms.href.toNormalform(true, false));
|
||||
prop.putHTML("content_item_href", ms.href.toNormalform(true, false));
|
||||
prop.put("content_item_code", sb.licensedURLs.aquireLicense(ms.href));
|
||||
|
@ -240,5 +241,4 @@ public class yacysearchitem {
|
|||
size = size / 1024;
|
||||
return size + " gbyte";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -512,6 +512,7 @@ public class HTTPClient {
|
|||
private void storeConnectionInfo(final HttpUriRequest httpUriRequest) {
|
||||
final int port = httpUriRequest.getURI().getPort();
|
||||
final String thost = httpUriRequest.getURI().getHost();
|
||||
assert thost != null : "uri = " + httpUriRequest.getURI().toString();
|
||||
ConnectionInfo.addConnection(new ConnectionInfo(
|
||||
httpUriRequest.getURI().getScheme(),
|
||||
port == 80 ? thost : thost + ":" + port,
|
||||
|
|
|
@ -347,7 +347,11 @@ public final class LoaderDispatcher {
|
|||
}
|
||||
|
||||
public void loadIfNotExistBackground(String url, File cache, long maxFileSize) {
|
||||
new Loader(url, cache, maxFileSize).start();
|
||||
new Loader(url, cache, maxFileSize, CrawlProfile.CacheStrategy.IFEXIST).start();
|
||||
}
|
||||
|
||||
public void loadIfNotExistBackground(String url, long maxFileSize) {
|
||||
new Loader(url, null, maxFileSize, CrawlProfile.CacheStrategy.IFEXIST).start();
|
||||
}
|
||||
|
||||
private class Loader extends Thread {
|
||||
|
@ -355,20 +359,22 @@ public final class LoaderDispatcher {
|
|||
private String url;
|
||||
private File cache;
|
||||
private long maxFileSize;
|
||||
private CrawlProfile.CacheStrategy cacheStrategy;
|
||||
|
||||
public Loader(String url, File cache, long maxFileSize) {
|
||||
public Loader(String url, File cache, long maxFileSize, CrawlProfile.CacheStrategy cacheStrategy) {
|
||||
this.url = url;
|
||||
this.cache = cache;
|
||||
this.maxFileSize = maxFileSize;
|
||||
this.cacheStrategy = cacheStrategy;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (this.cache.exists()) return;
|
||||
if (this.cache != null && this.cache.exists()) return;
|
||||
try {
|
||||
// load from the net
|
||||
Response response = load(request(new DigestURI(this.url), false, true), CrawlProfile.CacheStrategy.NOCACHE, this.maxFileSize);
|
||||
Response response = load(request(new DigestURI(this.url), false, true), this.cacheStrategy, this.maxFileSize);
|
||||
byte[] b = response.getContent();
|
||||
FileUtils.copy(b, this.cache);
|
||||
if (this.cache != null) FileUtils.copy(b, this.cache);
|
||||
} catch (MalformedURLException e) {} catch (IOException e) {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user