Don't delete torrent config file after error on initial startup (ticket #1658)

This commit is contained in:
zzz
2015-09-17 21:20:21 +00:00
parent 84abfa0190
commit bfc6534b20
3 changed files with 18 additions and 4 deletions

View File

@ -1755,6 +1755,8 @@ public class SnarkManager implements CompleteListener {
subdir.mkdirs(); subdir.mkdirs();
try { try {
DataHelper.storeProps(config, conf); DataHelper.storeProps(config, conf);
if (_log.shouldInfo())
_log.info("Saved config to " + conf);
} catch (IOException ioe) { } catch (IOException ioe) {
_log.error("Unable to save the config to " + conf); _log.error("Unable to save the config to " + conf);
} }
@ -2013,13 +2015,15 @@ public class SnarkManager implements CompleteListener {
File dir = getDataDir(); File dir = getDataDir();
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Directory Monitor loop over " + dir.getAbsolutePath()); _log.debug("Directory Monitor loop over " + dir.getAbsolutePath());
boolean ok;
try { try {
// Don't let this interfere with .torrent files being added or deleted // Don't let this interfere with .torrent files being added or deleted
synchronized (_snarks) { synchronized (_snarks) {
monitorTorrents(dir); ok = monitorTorrents(dir);
} }
} catch (Exception e) { } catch (Exception e) {
_log.error("Error in the DirectoryMonitor", e); _log.error("Error in the DirectoryMonitor", e);
ok = false;
} }
if (doMagnets) { if (doMagnets) {
// first run only // first run only
@ -2033,7 +2037,11 @@ public class SnarkManager implements CompleteListener {
addMessage(_("Up bandwidth limit is {0} KBps", _util.getMaxUpBW())); addMessage(_("Up bandwidth limit is {0} KBps", _util.getMaxUpBW()));
// To fix bug where files were left behind, // To fix bug where files were left behind,
// but also good for when user removes snarks when i2p is not running // 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) {} try { Thread.sleep(60*1000); } catch (InterruptedException ie) {}
} }
@ -2182,8 +2190,11 @@ public class SnarkManager implements CompleteListener {
/** /**
* caller must synchronize on _snarks * 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()); String fileNames[] = dir.list(TorrentFilenameFilter.instance());
List<String> foundNames = new ArrayList<String>(0); List<String> foundNames = new ArrayList<String>(0);
if (fileNames != null) { if (fileNames != null) {
@ -2213,6 +2224,7 @@ public class SnarkManager implements CompleteListener {
} catch (Exception e) { } catch (Exception e) {
addMessage(_("Error: Could not add the torrent {0}", name) + ": " + e); addMessage(_("Error: Could not add the torrent {0}", name) + ": " + e);
_log.error("Unable to add the torrent " + 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 */ /** translate */

View File

@ -1,6 +1,7 @@
2015-09-17 zzz 2015-09-17 zzz
* i2psnark: * i2psnark:
- Store magnet parameters across restart (ticket #1485) - Store magnet parameters across restart (ticket #1485)
- Don't delete torrent config file after error on initial startup (ticket #1658)
2015-09-16 zzz 2015-09-16 zzz
* Build: * Build:

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 4; public final static long BUILD = 5;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";