SimpleBackuper/_BlocksInfo.pm

filter: Statementstmt 17.9% 7 / 39 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 13.0% 9 / 69 CC 15 SCAR 53.6
CC
15
Cov
11%
_BlocksInfo
240.0
BEGIN
1.0
BEGIN
1.0
CRAP 211.9
« SimpleBackuper/StorageCheck.pm ↑ Summary SimpleBackuper/_BlockDelete.pm »
1 package App::SimpleBackuper;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub _BlocksInfo($$;$$$$);
7 0 ▶sub _BlocksInfo($$;$$$$) {
Subroutine _BlocksInfo: not called CC=15 SCAR=54.8
8 0 my($options, $state, $block_info, $parent_id, $path, $priority) = @_;
9
10 0 ▶ $block_info //= {};
Condition0%0/2
$block_info //= {}
l!l
00
MC/DC0%0/1
$block_info //= {}
$block_info
Truth table0%0/2
A
A= $block_info
Aresult
11
00
11 0 ▶ $parent_id //= 0;
Condition0%0/2
$parent_id //= 0
l!l
00
MC/DC0%0/1
$parent_id //= 0
$parent_id
Truth table0%0/2
A
A= $parent_id
Aresult
11
00
12 0 ▶ $path //= '/';
Condition0%0/2
$path //= "/"
l!l
00
MC/DC0%0/1
$path //= "/"
$path
Truth table0%0/2
A
A= $path
Aresult
11
00
13 0 ▶ $priority //= 0;
Condition0%0/2
$priority //= 0
l!l
00
MC/DC0%0/1
$priority //= 0
$priority
Truth table0%0/2
A
A= $priority
Aresult
11
00
14
15 0 my($oldest_backup_id) = $state->{db}->{backups}->unpack($state->{db}->{backups}->[0])->{id};
16
17 0 my $subfiles = $state->{db}->{files}->find_all({parent_id => $parent_id});
18 0 foreach my $file ( @$subfiles ) {
19
20 0 ▶ my $full_path = ($path eq '/' ? $path : "$path/").$file->{name};
Branch: 1 branch
BranchTrueFalseTotal
$path eq '/' ? : 0 0 0
21 0 my $prio = $priority;
22 0 ▶ while(my($mask, $p) = each %{ $options->{files} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$options{"files"};}) 0 0 0
23 0 ▶ $prio = $p if match_glob( $mask, $full_path );
Branch: 1 branch
BranchTrueFalseTotal
if match_glob($mask, $full_path) 0 0 0
24 }
25
26 0 _BlocksInfo($options, $state, $block_info, $file->{id}, $full_path, $prio);
27
28 0 my %file_added2block;
29 0 foreach my $version ( @{ $file->{versions} } ) {
30 0 ▶ next if ! $version->{block_id};
Branch: 1 branch
BranchTrueFalseTotal
unless $version->{"block_id"} 0 0 0
31
32 0 my $backup_id_score = $version->{backup_id_max} - $oldest_backup_id + 1;
33
34 0 ▶ $block_info->{ $version->{block_id} } ||= [0, 0, [], 0, 0];
Condition0%0/2
$$block_info{$version->{"block_id"}} ||= [0, 0, [], 0, 0]
l!l
00
MC/DC0%0/1
$$block_info{$version->{"block_id"}} ||= [0, 0, [], 0, 0]
$$block_info{$version->{"block_id"}}
Truth table0%0/2
A
A= $$block_info{$version->{"block_id"}}
Aresult
11
00
35 0 ▶ if($block_info->{ $version->{block_id} }->[0] < $backup_id_score * $prio) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$block_info{$version->{"block_id"}}[0] < $backup_id_score * $prio) 0 0 0
36 0 $block_info->{ $version->{block_id} }->[0] = $backup_id_score * $prio;
37 0 $block_info->{ $version->{block_id} }->[3] = $backup_id_score;
38 0 $block_info->{ $version->{block_id} }->[4] = $prio;
39 }
40 0 foreach my $part (@{ $version->{parts} }) {
41 0 $block_info->{ $version->{block_id} }->[1] += $part->{size};
42 }
43 0 ▶ if(! $file_added2block{ $version->{block_id} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($file_added2block{$version->{"block_id"}}) 0 0 0
44 0 push @{ $block_info->{ $version->{block_id} }->[2] }, $file->{parent_id}, $file->{id}, $full_path;
45 }
46
47 0 $file_added2block{ $version->{block_id} } = 1;
48 }
49 }
50
51 0 return $block_info;
52 }
53  
54 1 1;
« SimpleBackuper/StorageCheck.pm ↑ Summary SimpleBackuper/_BlockDelete.pm »