From 56e327d1dacb5b3453954b76a6d0edd30edb7a34 Mon Sep 17 00:00:00 2001 From: shengjia Date: Thu, 27 Oct 2016 09:42:25 +0300 Subject: [PATCH] patch for skip hash check --- libtransmission/rpcimpl.c | 1 + libtransmission/verify.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c index 44c5b58..2efaa68 100644 --- a/libtransmission/rpcimpl.c +++ b/libtransmission/rpcimpl.c @@ -386,6 +386,7 @@ torrentReannounce (tr_session * session, assert (idle_data == NULL); + skiphash(); torrents = getTorrents (session, args_in, &torrentCount); for (i=0; i 0) + if (!skiphashcheck && tr_sys_file_read_at (fd, buffer, bytesThisPass, filePos, &numRead, NULL) && numRead > 0) { bytesThisPass = numRead; tr_sha1_update (sha, buffer, bytesThisPass); @@ -116,7 +121,7 @@ verifyTorrent (tr_torrent * tor, bool * stopFlag) uint8_t hash[SHA_DIGEST_LENGTH]; tr_sha1_final (sha, hash); - hasPiece = !memcmp (hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH); + hasPiece = skiphashcheck || !memcmp (hash, tor->info.pieces[pieceIndex].hash, SHA_DIGEST_LENGTH); if (hasPiece || hadPiece) { @@ -154,6 +159,10 @@ verifyTorrent (tr_torrent * tor, bool * stopFlag) } } + if(skiphashcheck){ + skiphashcheck=false; + tr_logAddTorInfo (tor, "%s", _("skip hash check")); + } /* cleanup */ if (fd != TR_BAD_SYS_FILE) tr_sys_file_close (fd, NULL);