Author: nextgens
Date: 2007-11-19 13:10:47 +0000 (Mon, 19 Nov 2007)
New Revision: 15819

Modified:
   trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
Log:
StartupToadlet:
        * Attempt to show wrapper.log only if it has reasonnable chances to 
succeed
        * Strip everything before the first '\n' so that we don't start 
displaying from the middle of a line

Modified: trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StartupToadletServer.java    
2007-11-19 10:24:46 UTC (rev 15818)
+++ trunk/freenet/src/freenet/clients/http/StartupToadletServer.java    
2007-11-19 13:10:47 UTC (rev 15819)
@@ -101,10 +101,13 @@
                infoboxContent.addChild("#", "Your freenet node is starting up, 
please hold on.");

                 final File logs = new File("wrapper.log");
-                HTMLNode logInfobox = 
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-info", "Current 
status"));
-                HTMLNode logInfoboxContent = 
ctx.getPageMaker().getContentNode(logInfobox);
-                logInfoboxContent.addChild("%", FileUtil.readUTF(logs, 
logs.length()-2000).replaceAll("\n", "<br>\n"));
-                
+                if(logs.exists() && logs.isFile() && logs.canRead() && 
logs.length() > 2000) {
+                    HTMLNode logInfobox = 
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-info", "Current 
status"));
+                    HTMLNode logInfoboxContent = 
ctx.getPageMaker().getContentNode(logInfobox);
+                    String content = FileUtil.readUTF(logs, 
logs.length()-2000);
+                    int eol = content.indexOf('\n');
+                    logInfoboxContent.addChild("%", content.substring((eol < 0 
? 0 : eol)).replaceAll("\n", "<br>\n"));
+                }
                 //TODO: send a Retry-After header ?
                 writeHTMLReply(ctx, 503, desc, pageNode.generate());
             }


Reply via email to