* i2psnark: Fix peers stuck at uninteresting after magnet fetch

This commit is contained in:
zzz
2011-03-19 18:46:18 +00:00
parent b11516f758
commit c0422134f9
2 changed files with 10 additions and 2 deletions

View File

@ -426,6 +426,10 @@ public class PeerCoordinator implements PeerListener
_log.info("New connection to peer: " + peer + " for " + name); _log.info("New connection to peer: " + peer + " for " + name);
} }
// We may have gotten the metainfo after the peer was created.
if (metainfo != null)
peer.setMetaInfo(metainfo);
// Add it to the beginning of the list. // Add it to the beginning of the list.
// And try to optimistically make it a uploader. // And try to optimistically make it a uploader.
// Can't add to beginning since we converted from a List to a Queue // Can't add to beginning since we converted from a List to a Queue

View File

@ -496,10 +496,14 @@ class PeerState implements DataLoader
} }
/** /**
* Switch from magnet mode to normal mode * Switch from magnet mode to normal mode.
* If we already have the metainfo, this does nothing.
* @param meta non-null
* @since 0.8.4 * @since 0.8.4
*/ */
public void setMetaInfo(MetaInfo meta) { public void setMetaInfo(MetaInfo meta) {
if (metainfo != null)
return;
BitField oldBF = bitfield; BitField oldBF = bitfield;
if (oldBF != null) { if (oldBF != null) {
if (oldBF.size() != meta.getPieces()) if (oldBF.size() != meta.getPieces())
@ -511,7 +515,7 @@ class PeerState implements DataLoader
//bitfield = new BitField(meta.getPieces()); //bitfield = new BitField(meta.getPieces());
} }
metainfo = meta; metainfo = meta;
if (bitfield.count() > 0) if (bitfield != null && bitfield.count() > 0)
setInteresting(true); setInteresting(true);
} }