I2PSnark: Fix torrent-stopping (#766)

This commit is contained in:
dg2-new
2015-07-14 14:33:41 +00:00
parent 1ed1e4414b
commit 35b0e99ff0
4 changed files with 13 additions and 7 deletions

View File

@ -624,6 +624,11 @@ public class Snark
if (pc != null)
pc.halt();
Storage st = storage;
if (!fast)
// HACK: Needed a way to distinguish between user-stop and
// shutdown-stop. stopTorrent(true) is in stopAllTorrents().
// (#766)
stopped = true;
if (st != null) {
// TODO: Cache the config-in-mem to compare vs config-on-disk
// (needed for auto-save to not double-save in some cases)
@ -638,7 +643,9 @@ public class Snark
ioe.printStackTrace();
}
}
stopped = true;
if (fast)
// HACK: See above if(!fast)
stopped = true;
if (pc != null && _peerCoordinatorSet != null)
_peerCoordinatorSet.remove(pc);
if (_peerCoordinatorSet == null)

View File

@ -105,7 +105,7 @@ public class SnarkManager implements CompleteListener {
public static final String PROP_FILES_PUBLIC = "i2psnark.filesPublic";
public static final String PROP_OLD_AUTO_START = "i2snark.autoStart"; // oops
public static final String PROP_AUTO_START = "i2psnark.autoStart"; // convert in migration to new config file
public static final String DEFAULT_AUTO_START = "true";
public static final String DEFAULT_AUTO_START = "false";
//public static final String PROP_LINK_PREFIX = "i2psnark.linkPrefix";
//public static final String DEFAULT_LINK_PREFIX = "file:///";
public static final String PROP_STARTUP_DELAY = "i2psnark.startupDelay";
@ -1278,7 +1278,7 @@ public class SnarkManager implements CompleteListener {
running = true;
} else {
running = false;
}
}
// Were we running last time?
if (!dontAutoStart && shouldAutoStart() && running) {
torrent.startTorrent();
@ -1438,7 +1438,6 @@ public class SnarkManager implements CompleteListener {
Snark snark = getTorrentByInfoHash(metainfo.getInfoHash());
if (snark != null) {
addMessage(_("Torrent with this info hash is already running: {0}", snark.getBaseName()));
saveTorrentStatus(metainfo, bitfield, null, baseFile, true, 0, false); // no file priorities
return false;
} else {
saveTorrentStatus(metainfo, bitfield, null, baseFile, true, 0, true); // no file priorities
@ -2129,7 +2128,7 @@ public class SnarkManager implements CompleteListener {
try {
// Snark.fatal() throws a RuntimeException
// don't let one bad torrent kill the whole loop
addTorrent(name, null, !shouldAutoStart());
addTorrent(name, null, false);
} catch (Exception e) {
addMessage(_("Error: Could not add the torrent {0}", name) + ": " + e);
_log.error("Unable to add the torrent " + name, e);

View File

@ -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 = 15;
public final static long BUILD = 16;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -68,7 +68,7 @@ class IterativeLookupJob extends JobImpl {
}
RouterInfo ri = getContext().netDb().lookupRouterInfoLocally(peer);
if (ri == null) {
// Take it on faith that its ff to speed things up, we don't need the RI
// Take it on faith that it's ff to speed things up, we don't need the RI
// to query it.
// Zero-hop outbound tunnel will be failed in ISJ.sendQuery()
_search.newPeerToTry(peer);