diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java index ccc33172509de9b25fa57c19e93a76c17a1f22bf..1e6f152a92f6a5f9a5f1bea68538981796611841 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java +++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java @@ -1755,6 +1755,8 @@ public class SnarkManager implements CompleteListener { subdir.mkdirs(); try { DataHelper.storeProps(config, conf); + if (_log.shouldInfo()) + _log.info("Saved config to " + conf); } catch (IOException ioe) { _log.error("Unable to save the config to " + conf); } @@ -2013,13 +2015,15 @@ public class SnarkManager implements CompleteListener { File dir = getDataDir(); if (_log.shouldLog(Log.DEBUG)) _log.debug("Directory Monitor loop over " + dir.getAbsolutePath()); + boolean ok; try { // Don't let this interfere with .torrent files being added or deleted synchronized (_snarks) { - monitorTorrents(dir); + ok = monitorTorrents(dir); } } catch (Exception e) { _log.error("Error in the DirectoryMonitor", e); + ok = false; } if (doMagnets) { // first run only @@ -2033,7 +2037,11 @@ public class SnarkManager implements CompleteListener { addMessage(_("Up bandwidth limit is {0} KBps", _util.getMaxUpBW())); // To fix bug where files were left behind, // but also good for when user removes snarks when i2p is not running - cleanupTorrentStatus(); + // Don't run if there was an error, as we would delete the torrent config + // file(s) and we don't want to do that. We'll do the cleanup the next + // time i2psnark starts. See ticket #1658. + if (ok) + cleanupTorrentStatus(); } try { Thread.sleep(60*1000); } catch (InterruptedException ie) {} } @@ -2182,8 +2190,11 @@ public class SnarkManager implements CompleteListener { /** * caller must synchronize on _snarks + * + * @return success, false if an error adding any torrent. */ - private void monitorTorrents(File dir) { + private boolean monitorTorrents(File dir) { + boolean rv = true; String fileNames[] = dir.list(TorrentFilenameFilter.instance()); List<String> foundNames = new ArrayList<String>(0); if (fileNames != null) { @@ -2213,6 +2224,7 @@ public class SnarkManager implements CompleteListener { } catch (Exception e) { addMessage(_("Error: Could not add the torrent {0}", name) + ": " + e); _log.error("Unable to add the torrent " + name, e); + rv = false; } } } @@ -2233,6 +2245,7 @@ public class SnarkManager implements CompleteListener { } } } + return rv; } /** translate */ diff --git a/history.txt b/history.txt index 03c584c555725d4aba051196402339693d2b1b69..97cc89d6983d0dca7fbc7d1af3acb73e7d950482 100644 --- a/history.txt +++ b/history.txt @@ -1,6 +1,7 @@ 2015-09-17 zzz * i2psnark: - Store magnet parameters across restart (ticket #1485) + - Don't delete torrent config file after error on initial startup (ticket #1658) 2015-09-16 zzz * Build: diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index f6e6df3a5c0d10fbf1efc2f7069c342c2fe16f4e..4e28a2c8d2676ff98ee569a93ae883ef407d9461 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 4; + public final static long BUILD = 5; /** for example "-test" */ public final static String EXTRA = "";