* Console:

- More conversions to getBaseDir()
    * Router:
      - Improve installUpdates() error handling
    * BrowserLauncher:
      - Use temp dir
This commit is contained in:
zzz
2009-06-06 15:36:06 +00:00
parent 524a25eb2c
commit fd4e57aafc
6 changed files with 37 additions and 18 deletions

View File

@ -184,7 +184,8 @@ client applications can be found on our <a href="http://www.i2p2.i2p/download">d
<h2>Release history</h2>
<jsp:useBean class="net.i2p.router.web.ContentHelper" id="contenthelper" scope="request" />
<jsp:setProperty name="contenthelper" property="page" value="history.txt" />
<% File fpath = new java.io.File(net.i2p.I2PAppContext.getGlobalContext().getBaseDir(), "history.txt"); %>
<jsp:setProperty name="contenthelper" property="page" value="<%=fpath.getAbsolutePath()%>" />
<jsp:setProperty name="contenthelper" property="maxLines" value="500" />
<jsp:setProperty name="contenthelper" property="startAtBeginning" value="true" />
<jsp:getProperty name="contenthelper" property="textContent" />

View File

@ -19,7 +19,8 @@ if (System.getProperty("router.consoleNonce") == null) {
<div class="news" id="news">
<jsp:useBean class="net.i2p.router.web.ContentHelper" id="newshelper" scope="request" />
<jsp:setProperty name="newshelper" property="page" value="docs/news.xml" />
<% File fpath = new java.io.File(net.i2p.I2PAppContext.getGlobalContext().getBaseDir(), "docs/news.xml"); %>
<jsp:setProperty name="newshelper" property="page" value="<%=fpath.getAbsolutePath()%>" />
<jsp:setProperty name="newshelper" property="maxLines" value="300" />
<jsp:getProperty name="newshelper" property="content" />
@ -30,7 +31,8 @@ if (System.getProperty("router.consoleNonce") == null) {
<div class="main" id="main">
<jsp:useBean class="net.i2p.router.web.ContentHelper" id="contenthelper" scope="request" />
<jsp:setProperty name="contenthelper" property="page" value="docs/readme.html" />
<% fpath = new java.io.File(net.i2p.I2PAppContext.getGlobalContext().getBaseDir(), "docs/readme.html"); %>
<jsp:setProperty name="contenthelper" property="page" value="<%=fpath.getAbsolutePath()%>" />
<jsp:setProperty name="contenthelper" property="maxLines" value="300" />
<jsp:setProperty name="contenthelper" property="lang" value="<%=request.getParameter("lang")%>" />
<jsp:getProperty name="contenthelper" property="content" />

View File

@ -14,9 +14,10 @@
<a href="index.jsp"><img src="i2plogo.png" alt="Router Console" width="187" height="35" /></a><br />
</div>
<div class="toolbar">
<% if (new File("docs/toolbar.html").exists()) { %>
<% File path = new File(net.i2p.I2PAppContext.getGlobalContext().getBaseDir(), "docs/toolbar.html");
if (path.exists()) { %>
<jsp:useBean class="net.i2p.router.web.ContentHelper" id="toolbarhelper" scope="request" />
<jsp:setProperty name="toolbarhelper" property="page" value="docs/toolbar.html" />
<jsp:setProperty name="toolbarhelper" property="page" value="<%=path.getAbsolutePath()%>" />
<jsp:setProperty name="toolbarhelper" property="maxLines" value="300" />
<jsp:getProperty name="toolbarhelper" property="content" />
<% } else { %>

View File

@ -17,6 +17,7 @@ import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import net.i2p.I2PAppContext;
import net.i2p.util.ShellCommand;
/**
@ -68,10 +69,11 @@ public class UrlLauncher {
String browserString = "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" -nohome";
BufferedReader bufferedReader = null;
_shellCommand.executeSilentAndWait("regedit /E browser.reg \"HKEY_CLASSES_ROOT\\http\\shell\\open\\command\"");
File foo = new File(I2PAppContext.getGlobalContext().getTempDir(), "browser.reg");
_shellCommand.executeSilentAndWait("regedit /E \"" + foo.getAbsolutePath() + "\" \"HKEY_CLASSES_ROOT\\http\\shell\\open\\command\"");
try {
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("browser.reg"), "UTF-16"));
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(foo), "UTF-16"));
for (String line; (line = bufferedReader.readLine()) != null; ) {
if (line.startsWith("@=")) {
// we should really use the whole line and replace %1 with the url
@ -86,7 +88,7 @@ public class UrlLauncher {
} catch (IOException e) {
// No worries.
}
new File("browser.reg").delete();
foo.delete();
} catch (Exception e) {
// Defaults to IE.
} finally {

View File

@ -360,7 +360,7 @@
<copy file="build/BOB.jar" todir="pkg-temp/lib/" />
<copy file="build/sam.jar" todir="pkg-temp/lib/" />
<copy file="build/i2psnark.jar" todir="pkg-temp/lib" />
<!-- include systray fixes in 0.6.5 -->
<!-- include systray changes in 0.7.5 -->
<copy file="build/systray.jar" todir="pkg-temp/lib/" />
<copy file="build/susimail.war" todir="pkg-temp/webapps/" />
<copy file="build/susidns.war" todir="pkg-temp/webapps/" />

View File

@ -1076,6 +1076,7 @@ public class Router {
* Unzip update file found in the router dir OR base dir, to the base dir
*
* If we can't write to the base dir, complain.
* Note: _log not available here.
*/
private void installUpdates() {
File updateFile = new File(_context.getRouterDir(), UPDATE_FILE);
@ -1085,12 +1086,11 @@ public class Router {
exists = updateFile.exists();
}
if (exists) {
// do a simple permissions test, if it fails leave the file in place and don't restart
File test = new File(_context.getBaseDir(), "history.txt");
if ((!test.canWrite()) || (!_context.getBaseDir().canWrite())) {
String msg = "ERROR: No write permissions on " + _context.getBaseDir() +
" to extract software update file";
System.out.println(msg);
_log.log(Log.CRIT, msg);
if ((test.exists() && !test.canWrite()) || (!_context.getBaseDir().canWrite())) {
System.out.println("ERROR: No write permissions on " + _context.getBaseDir() +
" to extract software update file");
// carry on
return;
}
@ -1100,10 +1100,23 @@ public class Router {
System.out.println("INFO: Update installed");
else
System.out.println("ERROR: Update failed!");
boolean deleted = updateFile.delete();
if (!deleted) {
System.out.println("ERROR: Unable to delete the update file!");
updateFile.deleteOnExit();
if (!ok) {
// we can't leave the file in place or we'll continually restart, so rename it
File bad = new File(_context.getRouterDir(), "BAD-" + UPDATE_FILE);
boolean renamed = updateFile.renameTo(bad);
if (renamed) {
System.out.println("Moved update file to " + bad.getAbsolutePath());
} else {
System.out.println("Deleting file " + updateFile.getAbsolutePath());
ok = true; // so it will be deleted
}
}
if (ok) {
boolean deleted = updateFile.delete();
if (!deleted) {
System.out.println("ERROR: Unable to delete the update file!");
updateFile.deleteOnExit();
}
}
if (System.getProperty("wrapper.version") != null)
System.out.println("INFO: Restarting after update");