summaryrefslogtreecommitdiff
path: root/net-p2p/btcheck/files/patch-src_check.c
blob: a04553d433007a95d0e0f3a62a03be9a1812a74f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--- src/check.c.orig	2017-08-26 19:37:29 UTC
+++ src/check.c
@@ -36,7 +36,7 @@ int check(btree_t *torrentbtree)
 	btfile_t *btfile;
 	void *piecebuffer, *piecedigest;
 	size_t size, length;
-	int ret, pieceindex, failure;
+	int ret, pieceindex, failure, numpieces;
 		
 	torrentinfo = search_dict_value(torrentbtree, TorrentInfoSearch);
 	if (torrentinfo == NULL) {
@@ -80,6 +80,7 @@ int check(btree_t *torrentbtree)
 		fprintf(stderr, "Can't open btfile.\n");
 	}
 	
+	numpieces = (torrentinfolength + torrentinfopiecelength - 1) / torrentinfopiecelength;
 	failure = 0;
 	pieceindex = 0;
 	readlength = 0;
@@ -99,10 +100,10 @@ int check(btree_t *torrentbtree)
 		}	
 		if (ret == 0) {
 			if (Verbose >= 0)
-				printf("\rpiece[%d] OK ", pieceindex);
+				printf("\rpiece[%d/%d] OK ", pieceindex, numpieces);
 		} else {
 			if (Verbose >= 0)
-				printf("\rpiece[%d] BAD \n", pieceindex);
+				printf("\rpiece[%d/%d] BAD \n", pieceindex, numpieces);
 			failure++;
 		}
 		fflush(stdout);