From 80860232d7cef90f8e9956b13b5073b1c9e44b60 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 27 Feb 2016 16:17:25 +0000 Subject: [PATCH] i2ptunnel: Don't default to a private key file that exists (ticket #1628) Fix build.xml war dependency tracking --- apps/i2ptunnel/java/build.xml | 1 + .../java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/i2ptunnel/java/build.xml b/apps/i2ptunnel/java/build.xml index b4be255ccd..a009bc6979 100644 --- a/apps/i2ptunnel/java/build.xml +++ b/apps/i2ptunnel/java/build.xml @@ -235,6 +235,7 @@ <target name="warUpToDate"> <uptodate property="war.uptodate" targetfile="build/i2ptunnel.war" > <srcfiles dir= "../jsp" excludes="web.xml, web-fragment.xml, **/*.java, *.jsp" /> + <srcfiles dir= "build/obj" includes="**/ui/*.class **/web/*.class" /> </uptodate> <condition property="shouldListChanges2" > <and> diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java index 50d57b7107..40e2d439f5 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ui/GeneralHelper.java @@ -267,13 +267,21 @@ public class GeneralHelper { public String getPrivateKeyFile(int tunnel) { return getPrivateKeyFile(_group, tunnel); } - public static String getPrivateKeyFile(TunnelControllerGroup tcg, int tunnel) { + + public String getPrivateKeyFile(TunnelControllerGroup tcg, int tunnel) { TunnelController tun = getController(tcg, tunnel); if (tun != null && tun.getPrivKeyFile() != null) return tun.getPrivKeyFile(); if (tunnel < 0) tunnel = tcg == null ? 999 : tcg.getControllers().size(); - return "i2ptunnel" + tunnel + "-privKeys.dat"; + String rv = "i2ptunnel" + tunnel + "-privKeys.dat"; + // Don't default to a file that already exists, + // which could happen after other tunnels are deleted. + int i = 0; + while ((new File(_context.getConfigDir(), rv)).exists()) { + rv = "i2ptunnel" + tunnel + '.' + (++i) + "-privKeys.dat"; + } + return rv; } public String getClientInterface(int tunnel) { -- GitLab