forked from I2P_Developers/i2p.i2p
* i2psnark:
- More efficient metainfo handling, reduce instantiations
- Improved handling of storage errors
- Improved handling of duplicate file names
- More metainfo sanity checks
- Metadata transfer error handling improvements
- Code cleanup, remove dead and duplicated code
This commit is contained in:
@@ -191,14 +191,21 @@ class MagnetState {
|
||||
*/
|
||||
public MetaInfo buildMetaInfo() throws Exception {
|
||||
// top map has nothing in it but the info map (no announce)
|
||||
Map<String, Object> map = new HashMap();
|
||||
Map<String, BEValue> map = new HashMap();
|
||||
InputStream is = new ByteArrayInputStream(metainfoBytes);
|
||||
BDecoder dec = new BDecoder(is);
|
||||
BEValue bev = dec.bdecodeMap();
|
||||
map.put("info", bev);
|
||||
MetaInfo newmeta = new MetaInfo(map);
|
||||
if (!DataHelper.eq(newmeta.getInfoHash(), infohash))
|
||||
if (!DataHelper.eq(newmeta.getInfoHash(), infohash)) {
|
||||
// Disaster. Start over. ExtensionHandler will catch
|
||||
// the IOE and disconnect the peer, hopefully we will
|
||||
// find a new peer.
|
||||
// TODO: Count fails and give up eventually
|
||||
have = new BitField(totalChunks);
|
||||
requested = new BitField(totalChunks);
|
||||
throw new IOException("info hash mismatch");
|
||||
}
|
||||
return newmeta;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user