* i2psnark: Fix peers stuck at uninteresting after magnet fetch
This commit is contained in:
@ -426,6 +426,10 @@ public class PeerCoordinator implements PeerListener
|
||||
_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.
|
||||
// And try to optimistically make it a uploader.
|
||||
// Can't add to beginning since we converted from a List to a Queue
|
||||
|
@ -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
|
||||
*/
|
||||
public void setMetaInfo(MetaInfo meta) {
|
||||
if (metainfo != null)
|
||||
return;
|
||||
BitField oldBF = bitfield;
|
||||
if (oldBF != null) {
|
||||
if (oldBF.size() != meta.getPieces())
|
||||
@ -511,7 +515,7 @@ class PeerState implements DataLoader
|
||||
//bitfield = new BitField(meta.getPieces());
|
||||
}
|
||||
metainfo = meta;
|
||||
if (bitfield.count() > 0)
|
||||
if (bitfield != null && bitfield.count() > 0)
|
||||
setInteresting(true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user