Recheck
recheck
#
Module container Checker Class.
The CheckerClass takes a torrentfile and tha path to it’s contents. It will then iterate through every file and directory contained and compare their data to values contained within the torrent file. Completion percentages will be printed to screen for each file and at the end for the torrentfile as a whole.
Checker(metafile: str, path: str)
#
Check a given file or directory to see if it matches a torrentfile.
Public constructor for Checker class instance.
PARAMETER | DESCRIPTION |
---|---|
metafile |
Path to “.torrent” file.
TYPE:
|
path |
Path where the content is located in filesystem.
TYPE:
|
Example#
1 2 3 4 5 |
|
Validate data against hashes contained in .torrent file.
PARAMETER | DESCRIPTION |
---|---|
metafile |
path to .torrent file
TYPE:
|
path |
path to content or contents parent directory.
TYPE:
|
Source code in torrentfile\recheck.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
check_paths()
#
Gather all file paths described in the torrent file.
Source code in torrentfile\recheck.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
find_root(path: str) -> str
#
Check path for torrent content.
The path can be a relative or absolute filesystem path. In the case where the content is a single file, the path may point directly to the the file, or it may point to the parent directory. If content points to a directory. The directory will be checked to see if it matches the torrent’s name, if not the directories contents will be searched. The returned value will be the absolute path that matches the torrent’s name.
PARAMETER | DESCRIPTION |
---|---|
path |
root path to torrent content
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
root path to content |
Source code in torrentfile\recheck.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
iter_hashes() -> tuple
#
Produce results of comparing torrent contents piece by piece.
YIELDS | DESCRIPTION |
---|---|
chunck
|
hash of data found on disk
TYPE:
|
piece
|
hash of data when complete and correct
TYPE:
|
path
|
path to file being hashed
TYPE:
|
size
|
length of bytes hashed for piece
TYPE:
|
Source code in torrentfile\recheck.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
log_msg(*args, level: int = logging.INFO)
#
Log message msg
to logger and send msg
to callback hook.
PARAMETER | DESCRIPTION |
---|---|
*args |
formatting args for log message
TYPE:
|
level |
Log level for this message; default=
TYPE:
|
Source code in torrentfile\recheck.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
piece_checker()
#
Check individual pieces of the torrent.
RETURNS | DESCRIPTION |
---|---|
HashChecker | FeedChecker
|
Individual piece hasher. |
Source code in torrentfile\recheck.py
122 123 124 125 126 127 128 129 130 131 132 133 |
|
register_callback(hook)
classmethod
#
Register hooks from 3rd party programs to access generated info.
PARAMETER | DESCRIPTION |
---|---|
hook |
callback function for the logging feature.
TYPE:
|
Source code in torrentfile\recheck.py
110 111 112 113 114 115 116 117 118 119 120 |
|
results()
#
Generate result percentage and store for future calls.
Source code in torrentfile\recheck.py
135 136 137 138 139 140 141 142 143 144 145 146 |
|
walk_file_tree(tree: dict, partials: list)
#
Traverse File Tree dictionary to get file details.
Extract full pathnames, length, root hash, and layer hashes for each file included in the .torrent’s file tree.
PARAMETER | DESCRIPTION |
---|---|
tree |
File Tree dict extracted from torrent file.
TYPE:
|
partials |
list of intermediate pathnames.
TYPE:
|
Source code in torrentfile\recheck.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
FeedChecker(checker: Checker)
#
Bases: ProgMixin
Validates torrent content.
Seemlesly validate torrent file contents by comparing hashes in metafile against data on disk.
PARAMETER | DESCRIPTION |
---|---|
checker |
the checker class instance.
TYPE:
|
Generate hashes of piece length data from filelist contents.
Source code in torrentfile\recheck.py
327 328 329 330 331 332 333 334 335 336 337 338 |
|
__iter__()
#
Assign iterator and return self.
Source code in torrentfile\recheck.py
340 341 342 343 344 345 |
|
__next__()
#
Yield back result of comparison.
Source code in torrentfile\recheck.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
extract(path: str, partial: bytearray) -> bytearray
#
Split file paths contents into blocks of data for hash pieces.
PARAMETER | DESCRIPTION |
---|---|
path |
path to content.
TYPE:
|
partial |
any remaining content from last file.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bytearray
|
Hash digest for block of .torrent contents. |
Source code in torrentfile\recheck.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
|
iter_pieces()
#
Iterate through, and hash pieces of torrent contents.
YIELDS | DESCRIPTION |
---|---|
piece
|
hash digest for block of torrent data.
TYPE:
|
Source code in torrentfile\recheck.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
|
HashChecker(checker: Checker)
#
Bases: ProgMixin
Iterate through contents of meta data and verify with file contents.
PARAMETER | DESCRIPTION |
---|---|
checker |
the checker instance that maintains variables.
TYPE:
|
Construct a HybridChecker instance.
Source code in torrentfile\recheck.py
477 478 479 480 481 482 483 484 485 486 487 |
|
Padder(length, piece_length)
#
Padding class to generate padding hashes wherever needed.
PARAMETER | DESCRIPTION |
---|---|
length |
the total size of the mock file generating padding for.
|
piece_length |
the block size that each hash represents.
TYPE:
|
Construct padding class to Mock missing or incomplete files.
PARAMETER | DESCRIPTION |
---|---|
length |
size of the file
TYPE:
|
piece_length |
the piece length for each iteration.
TYPE:
|
Source code in torrentfile\recheck.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
|
__iter__()
#
Return self to correctly implement iterator type.
Source code in torrentfile\recheck.py
535 536 537 538 539 |
|
__next__() -> bytes
#
Iterate through seemingly endless sha256 hashes of zeros.
RETURNS | DESCRIPTION |
---|---|
tuple
|
returns the padding
TYPE:
|
RAISES | DESCRIPTION |
---|---|
StopIteration
|
Source code in torrentfile\recheck.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
|
__iter__()
#
Assign iterator and return self.
Source code in torrentfile\recheck.py
489 490 491 492 493 |
|
__next__()
#
Provide the result of comparison.
Source code in torrentfile\recheck.py
495 496 497 498 499 500 501 502 503 504 505 506 |
|
advance() -> tuple
#
Increment the number of pieces processed for the current file.
RETURNS | DESCRIPTION |
---|---|
tuple
|
the piece and size |
Source code in torrentfile\recheck.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
|
next_file() -> bool
#
Remove all references to processed files and prepare for the next.
RETURNS | DESCRIPTION |
---|---|
bool
|
if there is a next file found |
Source code in torrentfile\recheck.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
|
process_current() -> tuple
#
Gather necessary information to compare to metafile details.
RETURNS | DESCRIPTION |
---|---|
tuple
|
a tuple containing the layer, piece, current path and size |
RAISES | DESCRIPTION |
---|---|
StopIteration
|
Source code in torrentfile\recheck.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
|