- Fix dup torrent msg with magnets (tickets #433 and #504)

- Fix state when storage dies during transition out of magnet mode
    - Fix NPE in magnet mode
    - Error logging improvements
    - Support add-torrent with infohash alone
    - CSS tweaks
This commit is contained in:
zzz
2012-03-24 12:58:13 +00:00
parent 008c79e743
commit bdfca07626
8 changed files with 44 additions and 12 deletions

View File

@ -1031,6 +1031,8 @@ public class Snark
stopTorrent(); stopTorrent();
if (t != null) if (t != null)
s += ": " + t; s += ": " + t;
if (completeListener != null)
completeListener.fatal(this, s);
throw new RuntimeException(s, t); throw new RuntimeException(s, t);
} }
@ -1058,10 +1060,12 @@ public class Snark
* @since 0.8.4 * @since 0.8.4
*/ */
public void gotMetaInfo(PeerCoordinator coordinator, MetaInfo metainfo) { public void gotMetaInfo(PeerCoordinator coordinator, MetaInfo metainfo) {
meta = metainfo;
try { try {
storage = new Storage(_util, meta, this); // The following two may throw IOE...
storage = new Storage(_util, metainfo, this);
storage.check(rootDataDir); storage.check(rootDataDir);
// ... so don't set meta until here
meta = metainfo;
if (completeListener != null) { if (completeListener != null) {
String newName = completeListener.gotMetaInfo(this); String newName = completeListener.gotMetaInfo(this);
if (newName != null) if (newName != null)
@ -1169,6 +1173,11 @@ public class Snark
*/ */
public String gotMetaInfo(Snark snark); public String gotMetaInfo(Snark snark);
/**
* @since 0.9
*/
public void fatal(Snark snark, String error);
// not really listeners but the easiest way to get back to an optional SnarkManager // not really listeners but the easiest way to get back to an optional SnarkManager
public long getSavedTorrentTime(Snark snark); public long getSavedTorrentTime(Snark snark);
public BitField getSavedTorrentBitField(Snark snark); public BitField getSavedTorrentBitField(Snark snark);

View File

@ -1280,8 +1280,11 @@ public class SnarkManager implements Snark.CompleteListener {
return null; return null;
} }
saveTorrentStatus(meta, storage.getBitField(), null); // no file priorities saveTorrentStatus(meta, storage.getBitField(), null); // no file priorities
String name = (new File(getDataDir(), storage.getBaseName() + ".torrent")).getAbsolutePath(); // temp for addMessage() in case canonical throws
String name = storage.getBaseName();
try { try {
// _snarks must use canonical
name = (new File(getDataDir(), storage.getBaseName() + ".torrent")).getCanonicalPath();
// put the announce URL in the file // put the announce URL in the file
String announce = snark.getTrackerURL(); String announce = snark.getTrackerURL();
if (announce != null) if (announce != null)
@ -1305,6 +1308,14 @@ public class SnarkManager implements Snark.CompleteListener {
return null; return null;
} }
/**
* A Snark.CompleteListener method.
* @since 0.9
*/
public void fatal(Snark snark, String error) {
addMessage(_("Error on torrent {0}", snark.getName()) + ": " + error);
}
// End Snark.CompleteListeners // End Snark.CompleteListeners
/** /**

View File

@ -348,7 +348,7 @@ public class TrackerClient extends I2PAppThread
} // *** end of trackers loop here } // *** end of trackers loop here
// Get peers from PEX // Get peers from PEX
if (left > 0 && coordinator.needPeers() && (!meta.isPrivate()) && !stop) { if (left > 0 && coordinator.needPeers() && (meta == null || !meta.isPrivate()) && !stop) {
Set<PeerID> pids = coordinator.getPEXPeers(); Set<PeerID> pids = coordinator.getPEXPeers();
if (!pids.isEmpty()) { if (!pids.isEmpty()) {
_util.debug("Got " + pids.size() + " from PEX", Snark.INFO); _util.debug("Got " + pids.size() + " from PEX", Snark.INFO);
@ -370,7 +370,7 @@ public class TrackerClient extends I2PAppThread
// Get peers from DHT // Get peers from DHT
// FIXME this needs to be in its own thread // FIXME this needs to be in its own thread
if (_util.getDHT() != null && (!meta.isPrivate()) && !stop) { if (_util.getDHT() != null && (meta == null || !meta.isPrivate()) && !stop) {
int numwant; int numwant;
if (left == 0 || event.equals(STOPPED_EVENT) || !coordinator.needPeers()) if (left == 0 || event.equals(STOPPED_EVENT) || !coordinator.needPeers())
numwant = 1; numwant = 1;

View File

@ -544,6 +544,8 @@ public class I2PSnarkServlet extends DefaultServlet {
fetch.start(); fetch.start();
} else if (newURL.startsWith(MAGNET) || newURL.startsWith(MAGGOT)) { } else if (newURL.startsWith(MAGNET) || newURL.startsWith(MAGGOT)) {
addMagnet(newURL); addMagnet(newURL);
} else if (newURL.length() == 40 && newURL.replaceAll("[a-fA-F0-9]", "").length() == 0) {
addMagnet(MAGNET_FULL + newURL);
} else { } else {
_manager.addMessage(_("Invalid URL: Must start with \"http://\", \"{0}\", or \"{1}\"", MAGNET, MAGGOT)); _manager.addMessage(_("Invalid URL: Must start with \"http://\", \"{0}\", or \"{1}\"", MAGNET, MAGGOT));
} }
@ -1316,7 +1318,7 @@ public class I2PSnarkServlet extends DefaultServlet {
out.write(_("From URL")); out.write(_("From URL"));
out.write(":<td><input type=\"text\" name=\"newURL\" size=\"85\" value=\"" + newURL + "\""); out.write(":<td><input type=\"text\" name=\"newURL\" size=\"85\" value=\"" + newURL + "\"");
out.write(" title=\""); out.write(" title=\"");
out.write(_("Enter the torrent file download URL (I2P only), magnet link, or maggot link")); out.write(_("Enter the torrent file download URL (I2P only), magnet link, maggot link, or info hash"));
out.write("\"> \n"); out.write("\"> \n");
// not supporting from file at the moment, since the file name passed isn't always absolute (so it may not resolve) // not supporting from file at the moment, since the file name passed isn't always absolute (so it may not resolve)
//out.write("From file: <input type=\"file\" name=\"newFile\" size=\"50\" value=\"" + newFile + "\" /><br>"); //out.write("From file: <input type=\"file\" name=\"newFile\" size=\"50\" value=\"" + newFile + "\" /><br>");
@ -1509,11 +1511,11 @@ public class I2PSnarkServlet extends DefaultServlet {
"<tr><td>"); "<tr><td>");
out.write(_("Up bandwidth limit")); out.write(_("Up bandwidth limit"));
out.write(": <td><input type=\"text\" name=\"upBW\" class=\"r\" value=\"" out.write(": <td><input type=\"text\" name=\"upBW\" class=\"r\" value=\""
+ _manager.util().getMaxUpBW() + "\" size=\"3\" maxlength=\"3\" > KBps <i>("); + _manager.util().getMaxUpBW() + "\" size=\"3\" maxlength=\"3\" > KBps <i>");
out.write(_("Half available bandwidth recommended.")); out.write(_("Half available bandwidth recommended."));
out.write(" <a href=\"/config.jsp\" target=\"blank\">"); out.write("<br><a href=\"/config.jsp\" target=\"blank\">");
out.write(_("View or change router bandwidth")); out.write(_("View or change router bandwidth"));
out.write("</a>)</i><br>\n" + out.write("</a></i><br>\n" +
"<tr><td>"); "<tr><td>");
out.write(_("Use open trackers also")); out.write(_("Use open trackers also"));

View File

@ -1,3 +1,13 @@
2012-03-24 zzz
* GarlicConfig: Remove more unused methods
* i2psnark:
- Fix dup torrent msg with magnets (tickets #433 and #504)
- Fix state when storage dies during transition out of magnet mode
- Fix NPE in magnet mode
- Error logging improvements
- Support add-torrent with infohash alone
- CSS tweaks
2012-03-22 zzz 2012-03-22 zzz
* Home page: CSS tweaks * Home page: CSS tweaks
* Reseeder: Get rid of static instance, root in netDB, * Reseeder: Get rid of static instance, root in netDB,

View File

@ -93,7 +93,7 @@ body {
border: 1px solid #000; border: 1px solid #000;
overflow: auto; overflow: auto;
color: #26f; color: #26f;
max-height: 76px; max-height: 82px;
min-height: 45px; min-height: 45px;
width: auto; width: auto;
background: #2a192a url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center; background: #2a192a url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center;

View File

@ -92,7 +92,7 @@ body {
border: 1px solid #000; border: 1px solid #000;
overflow: auto; overflow: auto;
color: #26f; color: #26f;
max-height: 76px; max-height: 82px;
min-height: 45px; min-height: 45px;
width: auto; width: auto;
background: #eda url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center; background: #eda url('/themes/snark/ubergine/images/hat.png') no-repeat scroll right center;

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