line |
true |
false |
branch |
48
|
2 |
85 |
if (not $args or ref $args ne 'HASH') |
53
|
2 |
83 |
unless ($$args{'Path'}) |
60
|
1 |
82 |
unless (-f $$args{'Path'}) |
67
|
10 |
72 |
if ($$args{'Client'} and not blessed($$args{'Client'}) && $$args{'Client'}->isa('Net::BitTorrent')) |
75
|
5 |
67 |
if ($$args{'BlockLength'} and not $$args{'BlockLength'} =~ /^\d+$/) |
81
|
5 |
67 |
if ($$args{'Status'} and not $$args{'Status'} =~ /^\d+$/) |
87
|
67 |
5 |
defined $$args{'BaseDir'} ? : |
90
|
0 |
72 |
unless (sysopen $TORRENT_FH, $$args{'Path'}, 0) |
98
|
0 |
72 |
if (sysread($TORRENT_FH, $TORRENT_RAW, -s $$args{'Path'}) != -s $$args{'Path'}) |
112
|
1 |
71 |
unless ($raw_data{refaddr $self}) |
116
|
0 |
71 |
if (length unpack('H*', $raw_data{refaddr $self}{'info'}{'pieces'}) < 40) |
121
|
0 |
71 |
if (length(unpack 'H*', $raw_data{refaddr $self}{'info'}{'pieces'}) % 40) |
131
|
20 |
51 |
defined $$args{'BlockLength'} ? : |
142
|
53 |
18 |
if (defined $raw_data{refaddr $self}{'info'}{'files'}) { } |
167
|
0 |
0 |
if (defined $raw_data{refaddr $self}{'encoding'} and not $raw_data{refaddr $self}{'encoding'} =~ /^utf-?8$/i and not utf8::is_utf8($path) and require Encode) |
190
|
0 |
62 |
$raw_data{refaddr $self}{'announce'} ? : |
|
9 |
62 |
$raw_data{refaddr $self}{'announce-list'} ? : |
202
|
41 |
0 |
if ($$args{'Client'} and blessed($$args{'Client'}) and $$args{'Client'}->isa('Net::BitTorrent')) |
205
|
4 |
37 |
$raw_data{refaddr $self}{'nodes'} ? : |
214
|
0 |
71 |
if $$args{'Status'} & CHECKING() |
215
|
0 |
71 |
if $$args{'Status'} & CHECKED() |
216
|
0 |
71 |
if $$args{'Status'} & ERROR() |
217
|
0 |
71 |
if $$args{'Status'} & LOADED() |
225
|
0 |
71 |
if ($$args{'Resume'}) |
228
|
0 |
0 |
if (-f $$args{'Resume'}) |
233
|
0 |
0 |
if ($_resume_data) |
238
|
0 |
0 |
if ($$_resume_data{'.format'} and $$_resume_data{'.format'} eq 'Net::BitTorrent resume' and $$_resume_data{'.version'} and $$_resume_data{'.version'} <= 2) |
244
|
0 |
0 |
$$_resume_data{'peers'} ? : |
250
|
0 |
0 |
if (not -f $files{refaddr $self}[$_index]->path and $$_resume_data{'files'}[$_index]{'mtime'} or ((stat $files{refaddr $self}[$_index]->path)[9] or 0 != $$_resume_data{'files'}[$_index]{'mtime'})) |
264
|
0 |
0 |
if (not $_okay) { } |
276
|
0 |
0 |
if ${$status{refaddr $self};} & START_AFTER_CHECK() |
278
|
0 |
0 |
unless ${$status{refaddr $self};} & CHECKED() |
279
|
0 |
0 |
if ($start_after_check) |
313
|
0 |
71 |
if ($threads::shared::threads_shared) |
319
|
41 |
30 |
if ($$args{'Client'}) |
334
|
41 |
30 |
if $_start and ${$status{refaddr $self};} & QUEUED() |
360
|
0 |
210 |
$raw_data{refaddr(shift())}{'info'}{'private'} ? : |
365
|
20 |
5 |
$raw ? : |
372
|
0 |
234 |
if ${$status{refaddr $self};} & CHECKING() |
373
|
27 |
207 |
!(unpack('b*', $self->_wanted) =~ /1/) ? : |
388
|
0 |
503 |
if ${$status{refaddr $self};} & CHECKING() |
389
|
0 |
503 |
unless ${$status{refaddr $self};} & QUEUED() |
391
|
1428 |
1343 |
$$_{'Object'}->isa('Net::BitTorrent::Peer') && $$_{'Object'}->torrent && $$_{'Object'}->torrent eq $self ? : |
408
|
5 |
10 |
if ${$status{refaddr $self};} & CHECKING() |
409
|
5 |
5 |
if length ${$bitfield{refaddr $self};} != length $new_value |
417
|
0 |
5 |
if ${$status{refaddr $self};} & CHECKING() |
426
|
1 |
14 |
if ${$status{refaddr $self};} & STARTED() |
433
|
0 |
0 |
unless $value =~ /^\d+$/ |
452
|
721 |
8 |
$file->priority ? : |
|
721 |
8 |
if ($file->priority ? 1 : 0) |
453
|
721 |
0 |
$file->priority ? : |
474
|
0 |
36 |
unless $priority |
477
|
54 |
0 |
if not vec(${$bitfield{refaddr $self};}, $_, 1) |
486
|
0 |
23 |
if ${$status{refaddr $self};} & PAUSED() |
487
|
0 |
23 |
if ${$status{refaddr $self};} & CHECKING() |
492
|
0 |
23 |
if !${$status{refaddr $self};} & CHECKING() |
497
|
5 |
18 |
if ${$status{refaddr $self};} & START_AFTER_CHECK() |
499
|
23 |
0 |
unless ${$status{refaddr $self};} & CHECKED() |
501
|
0 |
23 |
if ${$status{refaddr $self};} & CHECKING() |
502
|
5 |
18 |
if ($start_after_check) |
508
|
0 |
10 |
if (!${$status{refaddr $self};} & QUEUED()) |
512
|
0 |
10 |
if (!${$status{refaddr $self};} & STARTED()) |
521
|
5 |
51 |
unless ${$status{refaddr $self};} & QUEUED() |
523
|
0 |
51 |
if ${$status{refaddr $self};} & ERROR() |
525
|
5 |
46 |
if ${$status{refaddr $self};} & PAUSED() |
526
|
46 |
5 |
unless (${$status{refaddr $self};} & STARTED()) |
537
|
0 |
7 |
unless ${$status{refaddr $self};} & QUEUED() |
542
|
7 |
0 |
if (${$status{refaddr $self};} & STARTED()) |
553
|
0 |
41 |
unless ($client and blessed $client and $client->isa('Net::BitTorrent')) |
560
|
0 |
41 |
if ($_client{refaddr $self} or ${$status{refaddr $self};} & QUEUED()) |
575
|
0 |
20 |
if ${$status{refaddr $self};} & CHECKING() |
576
|
0 |
20 |
unless ${$status{refaddr $self};} & QUEUED() |
577
|
0 |
20 |
unless $amount |
578
|
10 |
10 |
$amount =~ /^\d+$/ ? : |
583
|
0 |
18 |
if ${$status{refaddr $self};} & CHECKING() |
584
|
0 |
18 |
unless ${$status{refaddr $self};} & QUEUED() |
585
|
8 |
10 |
$amount =~ /^\d+$/ ? : |
590
|
30 |
183 |
unless defined $_client{refaddr $self} |
593
|
142 |
0 |
if @_ |
594
|
5 |
178 |
$self->is_complete ? : |
597
|
0 |
183 |
if ${$status{refaddr $self};} & CHECKING() |
598
|
0 |
183 |
unless ${$status{refaddr $self};} & STARTED() |
599
|
0 |
183 |
unless ${$status{refaddr $self};} & QUEUED() |
603
|
0 |
183 |
if scalar $self->peers >= $_client{refaddr $self}->_peers_per_torrent |
607
|
382 |
372 |
if $$_{'Object'}->isa('Net::BitTorrent::Peer') |
619
|
173 |
10 |
unless ($_nodes{refaddr $self}) |
620
|
128 |
45 |
unless $self->private |
631
|
117 |
66 |
unless $_nodes{refaddr $self} |
636
|
47 |
152 |
unless @nodes |
640
|
120 |
32 |
if scalar grep({sprintf('%s:%d', $_->host || '', $_->port || 0) eq $node;} @peers) |
645
|
0 |
32 |
if (defined $ok and $ok == 0) |
663
|
0 |
12 |
unless ref $tier eq 'ARRAY' |
673
|
0 |
41 |
if !${$status{refaddr $self};} & STARTED() |
674
|
0 |
41 |
if ${$status{refaddr $self};} & CHECKING() |
675
|
5 |
36 |
unless ${$status{refaddr $self};} & QUEUED() |
676
|
15 |
21 |
unless (defined $index and $index =~ /^\d+$/) |
681
|
3 |
18 |
$_working_pieces{refaddr $self}{$index} ? : |
688
|
4 |
18 |
if $self->is_complete |
689
|
0 |
18 |
if !${$status{refaddr $self};} & STARTED() |
690
|
0 |
18 |
if ${$status{refaddr $self};} & CHECKING() |
691
|
0 |
18 |
unless ${$status{refaddr $self};} & QUEUED() |
692
|
0 |
18 |
unless ($_client{refaddr $self}) |
697
|
0 |
18 |
if (!${$status{refaddr $self};} & STARTED() or ${$status{refaddr $self};} & CHECKING()) |
703
|
0 |
18 |
unless ($peer and blessed $peer and $peer->isa('Net::BitTorrent::Peer')) |
713
|
0 |
18 |
unless unpack('b*', $relevence) =~ /1/ |
714
|
0 |
18 |
sum(split(//, unpack('b*', $_wanted), 0)) <= length(unpack 'b*', $_wanted) * 0.1 ? : |
733
|
0 |
18 |
$unrequested_blocks > int($raw_data{refaddr $self}{'info'}{'piece length'} / $_block_length{refaddr $self}) / 4 ? : |
|
0 |
18 |
if (scalar grep({$$_{'Slow'} == 1;} values %{$_working_pieces{refaddr $self};}) >= 3) { } |
|
0 |
18 |
elsif (scalar values %{$_working_pieces{refaddr $self};} >= ($unrequested_blocks > int($raw_data{refaddr $self}{'info'}{'piece length'} / $_block_length{refaddr $self}) / 4 ? 0 : 1) + scalar(keys %{$_working_pieces{refaddr $self};})) { } |
741
|
0 |
0 |
if (vec($relevence, $index, 1) == 1) |
742
|
0 |
0 |
$endgame ? : |
|
0 |
0 |
if (($endgame ? index($_working_pieces{refaddr $self}{$index}{'Blocks_Received'}, '0', 0) : scalar grep({scalar keys %$_;} @{$_working_pieces{refaddr $self}{$index}{'Blocks_Requested'};})) != -1) |
783
|
0 |
0 |
if (vec($relevence, $index, 1) == 1) |
784
|
0 |
0 |
$endgame ? : |
|
0 |
0 |
if (($endgame ? index($_working_pieces{refaddr $self}{$index}{'Blocks_Received'}, '0', 0) : scalar grep({scalar keys %$_;} @{$_working_pieces{refaddr $self}{$index}{'Blocks_Requested'};})) != -1) |
804
|
0 |
18 |
unless keys %weights |
810
|
18 |
18 |
if ($rand_val <= 0 and vec($relevence, $i, 1) == 1) |
816
|
0 |
18 |
unless defined $index |
817
|
0 |
18 |
$index == int $size{refaddr $self} / $raw_data{refaddr $self}{'info'}{'piece length'} ? : |
827
|
18 |
0 |
$raw_data{refaddr $self}{'info'}{'piece length'} < $_block_length{refaddr $self} ? : |
837
|
0 |
18 |
$block_length_last ? : |
853
|
18 |
0 |
if ($piece) |
854
|
5 |
13 |
unless (defined $_working_pieces{refaddr $self}{$$piece{'Index'}}) |
861
|
18 |
0 |
$piece ? : |
868
|
0 |
3 |
if !${$status{refaddr $self};} & STARTED() |
869
|
0 |
3 |
if ${$status{refaddr $self};} & CHECKING() |
870
|
0 |
3 |
unless ${$status{refaddr $self};} & QUEUED() |
871
|
0 |
3 |
if (length($$data) + ($raw_data{refaddr $self}{'info'}{'piece length'} * $index + $offset) > $size{refaddr $self}) |
890
|
0 |
0 |
unless defined $files{refaddr $self}[$file_index]->size |
893
|
3 |
3 |
$total_offset + length($$data) > $files{refaddr $self}[$file_index]->size ? : |
898
|
0 |
6 |
unless $files{refaddr $self}[$file_index]->_open('w') |
900
|
0 |
6 |
unless $files{refaddr $self}[$file_index]->_write(substr($$data, 0, $this_write, '')) |
905
|
3 |
3 |
unless defined $files{refaddr $self}[$file_index] |
913
|
0 |
292 |
unless defined $index and $index =~ /^\d+$/ |
914
|
0 |
292 |
unless defined $offset and $offset =~ /^\d+$/ |
915
|
0 |
292 |
unless defined $length and $length =~ /^\d+$/ |
917
|
0 |
292 |
if ($length + ($raw_data{refaddr $self}{'info'}{'piece length'} * $index + $offset) > $size{refaddr $self}) |
936
|
0 |
19 |
unless defined $files{refaddr $self}[$file_index]->size |
939
|
55 |
253 |
$total_offset + $length >= $files{refaddr $self}[$file_index]->size ? : |
944
|
273 |
35 |
unless $files{refaddr $self}[$file_index]->_open('r') |
948
|
35 |
0 |
if $_data |
951
|
19 |
16 |
unless defined $files{refaddr $self}[$file_index] |
959
|
0 |
287 |
unless (defined $index and $index =~ /^\d+$/) |
965
|
23 |
264 |
$index == $self->piece_count - 1 ? : |
974
|
273 |
14 |
if (not $data or sha1_hex($$data) ne substr(unpack('H*', $raw_data{refaddr $self}{'info'}{'pieces'}), $index * 40, 40)) |
990
|
9 |
5 |
if (vec(${$bitfield{refaddr $self};}, $index, 1) == 0) |
1007
|
0 |
18 |
if !${$status{refaddr $self};} & STARTED() |
1008
|
0 |
18 |
if ${$status{refaddr $self};} & CHECKING() |
1009
|
0 |
18 |
unless ${$status{refaddr $self};} & QUEUED() |
1010
|
6 |
12 |
if $self->private |
1011
|
0 |
12 |
unless $_client{refaddr $self}->_use_dht |
1017
|
12 |
0 |
if $_client{refaddr $s}->_use_dht |
1033
|
0 |
20 |
unless ${$status{refaddr $self};} & STARTED() |
1034
|
0 |
20 |
if ${$status{refaddr $self};} & CHECKING() |
1035
|
0 |
20 |
unless ${$status{refaddr $self};} & QUEUED() |
1036
|
7 |
13 |
if $self->private |
1037
|
13 |
0 |
if $_client{refaddr $self}->_use_dht |
1044
|
0 |
29 |
unless ___check_event($type) |
1052
|
0 |
476 |
unless ___check_event($type) |
1057
|
233 |
243 |
if ${$status{refaddr $self};} & QUEUED() |
1058
|
43 |
433 |
$_event{refaddr $self}{$type} ? : |
1081
|
5 |
5 |
unless $file |
1091
|
5 |
0 |
${$status{refaddr $self};} & QUEUED() && !$self->private ? : |
1106
|
0 |
8 |
-f $_->path ? : |
1128
|
0 |
5 |
$_nodes ? : |
1133
|
0 |
5 |
unless open my $_RD, '>', $file |
1134
|
0 |
5 |
unless syswrite $_RD, bencode(\%resume_data) |
1177
|
474 |
2 |
vec($wanted, $_, 1) ? : |
|
0 |
476 |
$_working_pieces{refaddr $self}{$_} ? : |
|
10 |
476 |
vec(${$bitfield{refaddr $self};}, $_, 1) ? : |
1198
|
0 |
0 |
scalar keys %{$_working_pieces{refaddr $self}{$index}{'Blocks_Requested'}[$_];} ? : |
|
0 |
0 |
scalar keys %{$_working_pieces{refaddr $self}{$index}{'Blocks_Requested'}[$_];} == 1 ? : |
|
0 |
0 |
$_working_pieces{refaddr $self}{$index}{'Blocks_Received'}[$_] ? : |
1223
|
0 |
10 |
$self->private ? : |
|
6 |
4 |
@{$files{refaddr $self};} != 1 ? : |
|
10 |
0 |
@{$trackers{refaddr $self};} != 1 ? : |
|
15 |
10 |
!$advanced ? : |
1225
|
15 |
10 |
defined wantarray ? : |
1245
|
10 |
0 |
${$status{refaddr $self};} & LOADED() ? : |
|
10 |
0 |
${$status{refaddr $self};} & STARTED() ? : |
|
10 |
0 |
${$status{refaddr $self};} & CHECKING() ? : |
|
0 |
10 |
${$status{refaddr $self};} & START_AFTER_CHECK() ? : |
|
0 |
10 |
${$status{refaddr $self};} & CHECKED() ? : |
|
0 |
10 |
${$status{refaddr $self};} & PAUSED() ? : |
|
10 |
0 |
${$status{refaddr $self};} & QUEUED() ? : |
|
0 |
10 |
${$status{refaddr $self};} & ERROR() ? : |