I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 10872f75 authored by zzz's avatar zzz
Browse files

- Prevent torrent shutdown when changing file priority to skip

parent 20567ae7
No related branches found
No related tags found
No related merge requests found
...@@ -424,13 +424,22 @@ public class MetaInfo ...@@ -424,13 +424,22 @@ public class MetaInfo
} }
/** /**
* @return good
* @since 0.9.1 * @since 0.9.1
*/ */
boolean checkPiece(PartialPiece pp) throws IOException { boolean checkPiece(PartialPiece pp) {
MessageDigest sha1 = SHA1.getInstance(); MessageDigest sha1 = SHA1.getInstance();
int piece = pp.getPiece(); int piece = pp.getPiece();
byte[] hash;
byte[] hash = pp.getHash(); try {
hash = pp.getHash();
} catch (IOException ioe) {
// Could be caused by closing a peer connnection
// we don't want the exception to propagate through
// to Storage.putPiece()
_log.warn("Error checking", ioe);
return false;
}
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
if (hash[i] != piece_hashes[20 * piece + i]) if (hash[i] != piece_hashes[20 * piece + i])
return false; return false;
......
...@@ -308,6 +308,7 @@ class PeerState implements DataLoader ...@@ -308,6 +308,7 @@ class PeerState implements DataLoader
+ peer); + peer);
// Last chunk needed for this piece? // Last chunk needed for this piece?
// FIXME if priority changed to skip, we will think we're done when we aren't
if (getFirstOutstandingRequest(req.getPiece()) == -1) if (getFirstOutstandingRequest(req.getPiece()) == -1)
{ {
// warning - may block here for a while // warning - may block here for a while
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment