* 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:
zzz
2011-03-08 03:01:02 +00:00
parent 0e854623c1
commit f9b2c0bc63
8 changed files with 286 additions and 200 deletions

View File

@@ -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;
}
}