From 342543a6c4c4a691b90f7bd15f2d41c64fe0a6f3 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Thu, 25 Oct 2012 10:23:43 +0200 Subject: [PATCH] fix for host browser --- htroot/HostBrowser.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htroot/HostBrowser.java b/htroot/HostBrowser.java index 5e07bb96d..94c95d6de 100644 --- a/htroot/HostBrowser.java +++ b/htroot/HostBrowser.java @@ -145,6 +145,10 @@ public class HostBrowser { if (path.length() > 0) { boolean complete = post.getBoolean("complete"); + if (complete) { // we want only root paths for complete lists + p = path.indexOf('/', 10); + if (p > 0) path = path.substring(0, p + 1); + } prop.put("files_complete", complete ? 1 : 0); prop.put("files_complete_path", path); p = path.substring(0, path.length() - 1).lastIndexOf('/'); @@ -172,13 +176,12 @@ public class HostBrowser { while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) { String u = (String) doc.getFieldValue(YaCySchema.sku.getSolrFieldName()); hostsize++; - boolean considerPath = complete || u.startsWith(path); - if (considerPath) storedDocs.add(u); + if (complete || u.startsWith(path)) storedDocs.add(u); // collect inboundlinks to browse the host Iterator links = URIMetadataNode.getLinks(doc, true); while (links.hasNext()) { u = links.next(); - if (considerPath && !storedDocs.contains(u)) inboundLinks.add(u); + if ((complete || u.startsWith(path)) && !storedDocs.contains(u)) inboundLinks.add(u); } // collect outboundlinks to browse to the outbound @@ -208,8 +211,9 @@ public class HostBrowser { // distinguish files and folders Map list = new TreeMap(); int pl = path.length(); + String file; for (Map.Entry entry: files.entrySet()) { - String file = entry.getKey().substring(pl); + file = entry.getKey().substring(pl); p = file.indexOf('/'); if (p < 0) { // this is a file