| 1 | package Langertha::Holmgang::Sim::Linux::Backup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Backup and restore on a simulated Linux server — tar, rsync, restic, sha256sum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Digest::SHA (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use JSON::MaybeXS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Time::Local (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | my $T = JSON::MaybeXS::true(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 87 | ▶ | sub _lx { 'Langertha::Holmgang::Sim::Linux' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lx: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 87 | ▶ | sub _L { my $n = shift; return _lx()->can($n)->(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_L: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | ▶ | sub _cwd { $Langertha::Holmgang::Sim::Linux::CWD_DIR } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cwd: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 68 | ▶ | sub _abs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_abs: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 68 | my ($p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 68 | ▶ | return $p if $p =~ m{\A/}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | my $c = _cwd() // '/root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_cwd() // "/root"
MC/DC0%0/1
_cwd() // "/root"
_cwd()
Truth table50%1/2
A
A= _cwd()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | $p =~ s{\A\./}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | return $p eq '.' ? $c : ( $c eq '/' ? "/$p" : "$c/$p" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 22 | ▶ | sub _now_text { 'Oct 20 12:00' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_now_text: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Kopie eines Eintrags; erhalten (-a/-p, tar/restic als root) oder neu (root, umask 022) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 49 | ▶ | sub copy_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_entry: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 49 | my ( $e, $keep ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 49 | ▶ | my %n = ref $e eq 'HASH' ? %$e : ( content => $e ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 49 | ▶ | delete @n{qw( open_by tar )} if !$n{tar}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 49 | delete $n{open_by}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 49 | ▶ | unless ($keep) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 17 | $n{owner} = 'root'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 17 | $n{group} = 'root'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 17 | ▶ | $n{mode} = sprintf '%04o', oct( $n{mode} // '0644' ) & ~022; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$n{"mode"} // "0644"
MC/DC100%1/1
$n{"mode"} // "0644"
$n{"mode"}
Truth table100%2/2
A
A= $n{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 17 | $n{mtime} = _now_text(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 49 | return \%n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 57 | ▶ | sub _entry { my ( $dev, $p ) = @_; my $e = ( $dev->{files} || {} )->{$p}; return undef unless defined $e; return ref $e eq 'HASH' ? $e : { content => $e } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_entry: called CC=4 SCAR=14.2
Branch: 2 branches
Condition50%1/2
$$dev{'files'} || {}
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 24 | ▶ | sub _put { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_put: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 24 | my ( $dev, $path, $e ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 24 | ▶ | my $old = ( $dev->{files} || {} )->{$path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$dev{'files'} || {}
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( ref $old eq 'HASH' && $old->{open_by} ) { $e = { %$e, open_by => $old->{open_by} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $old eq "HASH" and $$old{"open_by"}
MC/DC0%0/2
ref $old eq "HASH" and $$old{"open_by"}
ref $old eq "HASH"
$$old{"open_by"}
Truth table66%2/3
A and B
A= ref $old eq "HASH"B= $$old{"open_by"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 24 | $dev->{files}{$path} = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # --- tar --------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | sub _tar_glob { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tar_glob: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | my ($g) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ( my $re = quotemeta $g ) =~ s/\\\*/.*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | $re =~ s/\\\?/./g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | return qr/\A$re(?:\/.*)?\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # --exclude wie GNU tar (nicht verankert): das Muster passt auf den ganzen Namen oder auf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # ein Stueck ab einer Komponente (cache trifft daten/cache und alles darunter) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 29 | ▶ | sub _tar_excluded { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tar_excluded: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 29 | my ( $rel, @ex ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 29 | my @seg = split m{/}, $rel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 29 | for my $x (@ex) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 4 | ( my $pat = $x ) =~ s{\A(?:\./|/+)}{}; # wie das Mitglied: ohne ./ und fuehrendes / | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | $pat =~ s{/+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | my $re = _tar_glob($pat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | return 1 if grep { join( '/', @seg[ $_ .. $#seg ] ) =~ $re } 0 .. $#seg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 27 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 16 | ▶ | sub tar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tar: called CC=94 SCAR=52.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 16 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 16 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 16 | my ( $mode, $file, $dir, $strip, $verbose, $keep, $stdout, $remove, @lists, @ex, @mem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 16 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 16 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 31 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 31 | ▶ | if ( $first && $x =~ /\A[a-zA-Z]+\z/ && $x =~ /[cxt]/ ) { $x = "-$x" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$first and $x =~ /\A[a-zA-Z]+\z/ and $x =~ /[cxt]/
$first and $x =~ /\A[a-zA-Z]+\z/
MC/DC66%2/3
$first and $x =~ /\A[a-zA-Z]+\z/ and $x =~ /[cxt]/
$first
$x =~ /\A[a-zA-Z]+\z/
$x =~ /[cxt]/
Truth table75%3/4
A and B and C
A= $firstB= $x =~ /\A[a-zA-Z]+\z/C= $x =~ /[cxt]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 31 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ( $x =~ /\A--(create|extract|get|list)\z/ ) { $mode = { create => 'c', extract => 'x', get => 'x', list => 't' }->{$1} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 16 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | elsif ( $x =~ /\A--file=(.+)\z/ ) { $file = $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | elsif ( $x eq '--file' ) { $file = shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | elsif ( $x =~ /\A--directory=(.+)\z/ ) { $dir = $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 3 | ▶ | elsif ( $x eq '--directory' || $x eq '-C' ) { $dir = shift @a } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$x eq "--directory" or $x eq "-C"
MC/DC50%1/2
$x eq "--directory" or $x eq "-C"
$x eq "--directory"
$x eq "-C"
Truth table66%2/3
A or B
A= $x eq "--directory"B= $x eq "-C"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | elsif ( $x =~ /\A--strip-components=(\d+)\z/ ) { $strip = $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | elsif ( $x =~ /\A--exclude=(.+)\z/ ) { push @ex, $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | elsif ( $x eq '--exclude' ) { push @ex, shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | elsif ( $x eq '--keep-old-files' ) { $keep = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | elsif ( $x eq '--to-stdout' ) { $stdout = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | elsif ( $x eq '--verbose' ) { $verbose = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | elsif ( $x =~ /\A--files-from=(.+)\z/ ) { push @lists, $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | elsif ( $x eq '--files-from' ) { push @lists, shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | elsif ( $x eq '--remove-files' ) { $remove = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | elsif ( $x =~ /\A--/ ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | elsif ( $x =~ /\A-([a-zA-Z]+)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 17 | my @f = split //, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 17 | ▶ | while ( defined( my $c = shift @f ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 52 | ▶ | if ( $c =~ /[cxt]/ ) { $mode = $c } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | elsif ( $c eq 'v' ) { $verbose = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | elsif ( $c eq 'k' ) { $keep = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | elsif ( $c eq 'O' ) { $stdout = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 16 | ▶ | elsif ( $c eq 'f' ) { $file = @f ? join( '', splice @f ) : shift @a } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | elsif ( $c eq 'C' ) { $dir = shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | elsif ( $c eq 'T' ) { push @lists, @f ? join( '', splice @f ) : shift @a } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 7 | else { push @mem, $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 16 | ▶ | return ( "tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options\nTry 'tar --help' or 'tar --usage' for more information.", 0 ) unless $mode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 16 | ▶ | return ( "tar: Refusing to read archive contents from terminal (missing -f option?)\ntar: Error is not recoverable: exiting now", 0 ) unless defined $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 16 | $file = _abs($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 16 | for my $l (@lists) { # -T liste | --files-from=liste (- = Eingabe): ein Mitglied je Zeile | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | my $t = $l eq '-' ? $ctx->{stdin} // '' : _L( '_file_text', $dev, _abs($l) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$ctx{"stdin"} // ""
MC/DC0%0/1
$$ctx{"stdin"} // ""
$$ctx{"stdin"}
Truth table50%1/2
A
A= $$ctx{"stdin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | return ( "tar: $l: Cannot open: No such file or directory\ntar: Error is not recoverable: exiting now", 0 ) unless defined $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | push @mem, grep { length } split /\n/, $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 16 | ▶ | if ( $mode eq 'c' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | ▶ | return ( "tar: Cowardly refusing to create an empty archive\nTry 'tar --help' or 'tar --usage' for more information.", 0 ) unless @mem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | my %m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | my @o; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # Mitglieder heissen wie angegeben (relativ zu -C bzw. dem aktuellen Verzeichnis), ohne fuehrendes / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | ▶ | my $base = defined $dir ? _abs($dir) : _cwd() // '/root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
_cwd() // "/root"
MC/DC0%0/1
_cwd() // "/root"
_cwd()
Truth table50%1/2
A
A= _cwd()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 5 | for my $arg (@mem) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 7 | ▶ | my $p = $arg =~ m{\A/} ? $arg : ( $base eq '/' ? '' : $base ) . '/' . ( $arg =~ s{\A\./?}{}r ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | $p =~ s{(?<=.)/+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 7 | ▶ | my @f = _entry( $dev, $p ) ? ($p) : _L( '_under', $dev, $p ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 7 | ▶ | return ( "tar: $arg: Cannot stat: No such file or directory\ntar: Exiting with failure status due to previous errors", 0 ) unless @f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | ( my $name = $arg ) =~ s{\A/+}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 7 | $name =~ s{/+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 7 | for my $f (@f) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 11 | my $rel = $name . substr( $f, length $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 11 | $rel =~ s{\A/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 11 | ▶ | next if _tar_excluded( $rel, @ex ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 9 | $m{$rel} = copy_entry( _entry( $dev, $f ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 9 | ▶ | push @o, $rel if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # Groesse: die Mitglieder plus Kopf (ungepackt gerechnet; ein leeres Archiv zeigt ls nicht als 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | my $sum = 10240; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | $sum += _L( '_file_size', $_ ) for values %m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 5 | _put( $dev, $file, { tar => \%m, owner => 'root', group => 'root', mode => '0644', mtime => _now_text(), content => '', size => $sum } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | ▶ | if ($remove) { # --remove-files: die Quellen nach dem Packen entfernen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | for my $arg (@mem) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | ▶ | my $p = $arg =~ m{\A/} ? $arg : ( $base eq '/' ? '' : $base ) . '/' . ( $arg =~ s{\A\./?}{}r ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | _L( '_rm', $dev, [ '-rf', $p =~ s{(?<=.)/+\z}{}r ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 5 | ▶ | return ( join( "\n", ( grep { m{\A/} } @mem ) ? "tar: Removing leading `/' from member names" : (), @o ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 11 | my $ar = _entry( $dev, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 11 | ▶ | return ( "tar: $file: Cannot open: No such file or directory\ntar: Error is not recoverable: exiting now", 0 ) unless $ar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 11 | my $members = $ar->{tar}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 11 | ▶ | return ( "tar: This does not look like a tar archive\ntar: Exiting with failure status due to previous errors", 0 ) unless ref $members eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 11 | my @names = sort keys %$members; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 11 | ▶ | if ( $ar->{corrupt} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | my @half = @names[ 0 .. int( $#names / 2 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | ▶ | return ( join( "\n", ( $mode eq 't' ? @half : () ), 'gzip: stdin: unexpected end of file', 'tar: Unexpected EOF in archive', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 'tar: Error is not recoverable: exiting now' ), 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 10 | my @want = map { s{\A/+}{}r } @mem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 10 | my @sel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | my %hit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 10 | for my $n (@names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 18 | ▶ | next if _tar_excluded( $n, @ex ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 18 | ▶ | if (@want) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 8 | ▶ | my ($w) = grep { my $x = $_ =~ s{/+\z}{}r; $n eq $x || index( $n, "$x/" ) == 0 } @want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$n eq $x || index($n, "$x/") == 0
MC/DC50%1/2
$n eq $x || index($n, "$x/") == 0
$n eq $x
index($n, "$x/") == 0
Truth table66%2/3
A || B
A= $n eq $xB= index($n, "$x/") == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 8 | ▶ | next unless defined $w; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | $hit{$w} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 13 | push @sel, $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 10 | my @miss = grep { !$hit{$_} } @want; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 10 | ▶ | my $err = @miss ? join( "\n", ( map {"tar: $_: Not found in archive"} @miss ), 'tar: Exiting with failure status due to previous errors' ) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 10 | ▶ | if ( $mode eq 't' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 4 | ▶ | my @l = $verbose ? map { my $e = $members->{$_}; sprintf '%s %s/%s %8d 2026-%s %s', _L( '_mode_text', oct( $e->{mode} // '0644' ) ), $e->{owner} // 'root', $e->{group} // 'root', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | _L( '_file_size', $e ), _date( $e->{mtime} ), $_ } @sel : @sel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$$e{"mode"} // "0644"
$$e{"owner"} // "root"
$$e{"group"} // "root"
MC/DC0%0/1
$$e{"mode"} // "0644"
$$e{"mode"}
MC/DC0%0/1
$$e{"owner"} // "root"
$$e{"owner"}
MC/DC0%0/1
$$e{"group"} // "root"
$$e{"group"}
Truth table50%1/2
A
A= $$e{"mode"}
Truth table50%1/2
A
A= $$e{"owner"}
Truth table50%1/2
A
A= $$e{"group"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | ▶ | return ( join( "\n", @l, defined $err ? $err : () ), defined $err ? 0 : 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | ▶ | if ($stdout) { return ( join( '', map { $members->{$_}{content} // '' } @sel ) =~ s/\n\z//r . ( defined $err ? "\n$err" : '' ), defined $err ? 0 : 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition50%1/2
$$members{$_}{"content"} // ""
MC/DC0%0/1
$$members{$_}{"content"} // ""
$$members{$_}{"content"}
Truth table50%1/2
A
A= $$members{$_}{"content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | ▶ | my $base = defined $dir ? _abs($dir) : _cwd() // '/root'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
_cwd() // "/root"
MC/DC100%1/1
_cwd() // "/root"
_cwd()
Truth table100%2/2
A
A= _cwd()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | return ( "tar: $base: Cannot open: No such file or directory\ntar: Error is not recoverable: exiting now", 0 ) unless _L( '_is_dir', $dev, $base ) || $base =~ m{\A/(?:tmp|root|srv|var|etc|opt|home|restore|mnt)\b}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_L("_is_dir", $dev, $base) or $base =~ m[\A/(?:tmp|root|srv|var|etc|opt|home|restore|mnt)\b]
MC/DC0%0/2
_L("_is_dir", $dev, $base) or $base =~ m[\A/(?:tmp|root|srv|var|etc|opt|home|restore|mnt)\b]
_L("_is_dir", $dev, $base)
$base =~ m[\A/(?:tmp|root|srv|var|etc|opt|home|restore|mnt)\b]
Truth table33%1/3
A or B
A= _L("_is_dir", $dev, $base)B= $base =~ m[\A/(?:tmp|root|srv|var|etc|opt|home|restore|mnt)\b]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | my @o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | for my $n (@sel) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | my @seg = split m{/}, $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 6 | ▶ | next if $strip && @seg <= $strip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$strip and @seg <= $strip
MC/DC0%0/2
$strip and @seg <= $strip
$strip
@seg <= $strip
Truth table33%1/3
A and B
A= $stripB= @seg <= $strip
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 6 | ▶ | my $rel = join '/', @seg[ ( $strip // 0 ) .. $#seg ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$strip // 0
MC/DC0%0/1
$strip // 0
$strip
Truth table50%1/2
A
A= $strip
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 6 | ▶ | my $to = ( $base eq '/' ? '' : $base ) . "/$rel"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | ▶ | if ( $keep && _entry( $dev, $to ) ) { push @o, "tar: $rel: Cannot open: File exists"; $err //= 'tar: Exiting with failure status due to previous errors'; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$keep and _entry($dev, $to)
$err //= "tar: Exiting with failure status due to previous errors"
MC/DC50%1/2
$keep and _entry($dev, $to)
$keep
_entry($dev, $to)
MC/DC100%1/1
$err //= "tar: Exiting with failure status due to previous errors"
$err
Truth table66%2/3
A and B
A= $keepB= _entry($dev, $to)
Truth table100%2/2
A
A= $err
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | _put( $dev, $to, copy_entry( $members->{$n}, 1 ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | ▶ | $dev->{dirs}{$_} //= {} for grep { !_L( '_is_dir', $dev, $_ ) } _parents($to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$dev{"dirs"}{$_} //= {}
MC/DC0%0/1
$$dev{"dirs"}{$_} //= {}
$$dev{"dirs"}{$_}
Truth table0%0/2
A
A= $$dev{"dirs"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | push @o, $n if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | ▶ | return ( join( "\n", @o, defined $err ? $err : () ), defined $err ? 0 : 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 4 | ▶ | sub _parents { my ($p) = @_; my @s = split m{/}, $p; return map { join '/', @s[ 0 .. $_ ] } 1 .. $#s - 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parents: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | sub _date { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | my ($m) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | my %mon = ( Jan => '01', Feb => '02', Mar => '03', Apr => '04', May => '05', Jun => '06', Jul => '07', Aug => '08', Sep => '09', Oct => '10', Nov => '11', Dec => '12' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | return '10-20 12:00' unless defined $m && $m =~ /\A(\w{3})\s+(\d+)\s+(\d+:\d+)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $m and $m =~ /\A(\w{3})\s+(\d+)\s+(\d+:\d+)\z/
MC/DC0%0/2
defined $m and $m =~ /\A(\w{3})\s+(\d+)\s+(\d+:\d+)\z/
defined $m
$m =~ /\A(\w{3})\s+(\d+)\s+(\d+:\d+)\z/
Truth table33%1/3
A and B
A= defined $mB= $m =~ /\A(\w{3})\s+(\d+)\s+(\d+:\d+)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | ▶ | return sprintf '%s-%02d %s', $mon{$1} // '10', $2, $3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$mon{$1} // 10
MC/DC0%0/1
$mon{$1} // 10
$mon{$1}
Truth table50%1/2
A
A= $mon{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | sub gzip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gzip: called CC=6 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | my ( $dev, $av ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | my ($f) = grep { !/\A-/ } @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | return ( '', 0 ) unless grep { $_ eq '-t' || $_ eq '--test' } @$av; # nur Pruefen ist nachgebildet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ eq '-t' || $_ eq '--test'
MC/DC50%1/2
$_ eq '-t' || $_ eq '--test'
$_ eq '-t'
$_ eq '--test'
Truth table66%2/3
A || B
A= $_ eq '-t'B= $_ eq '--test'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | my $e = _entry( $dev, _abs( $f // '' ) ) or return ( "gzip: $f: No such file or directory", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$f // ""
MC/DC0%0/1
$f // ""
$f
Truth table50%1/2
A
A= $f
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | return ( "gzip: $f: unexpected end of file", 0 ) if $e->{corrupt}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | return ( '', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # --- sha256sum ----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 5 | ▶ | sub _sha { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sha: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | my ($e) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 5 | ▶ | return $e->{sha256} if defined $e->{sha256}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | return Digest::SHA::sha256_hex( _L( '_digest_bytes', $e, $e->{content} ) ); # ohne Inhalt: Daten des Eintrags | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | ▶ | sub sha256sum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sha256sum: called CC=16 SCAR=29.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | my ( $dev, $av ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | my $check = grep { $_ eq '-c' || $_ eq '--check' } @a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_ eq '-c' || $_ eq '--check'
MC/DC50%1/2
$_ eq '-c' || $_ eq '--check'
$_ eq '-c'
$_ eq '--check'
Truth table66%2/3
A || B
A= $_ eq '-c'B= $_ eq '--check'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | my $quiet = grep { $_ eq '--quiet' } @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | my @f = grep { !/\A-/ } @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | my ( @l, $ok, $bad ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | if ($check) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | for my $lf (@f) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | my $t = _L( '_file_text', $dev, _abs($lf) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | ▶ | return ( "sha256sum: $lf: No such file or directory", 0 ) unless defined $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | for my $line ( split /\n/, $t ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | ▶ | my ( $h, $p ) = $line =~ /\A([0-9a-f]{64})\s+\*?(.+?)\s*\z/ or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | ▶ | my $path = $p =~ m{\A/} ? $p : do { ( my $d = _abs($lf) ) =~ s{/[^/]*\z}{}; _cwd() ? _abs($p) : "$d/$p" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | my $e = _entry( $dev, $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if ( !$e ) { push @l, "sha256sum: $p: No such file or directory", "$p: FAILED open or read"; $ok = 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ▶ | elsif ( _sha($e) eq $h ) { push @l, "$p: OK" unless $quiet } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | else { push @l, "$p: FAILED"; $bad++; $ok = 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | push @l, "sha256sum: WARNING: $bad computed checksum" . ( $bad == 1 ? '' : 's' ) . ' did NOT match' if $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | return ( join( "\n", @l ), $ok ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | for my $p (@f) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | my $e = _entry( $dev, _abs($p) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( !$e ) { push @l, "sha256sum: $p: No such file or directory"; $ok = 0; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | push @l, _sha($e) . " $p"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | return ( join( "\n", @l ), $ok ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # --- rsync --------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 12 | ▶ | sub _loc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_loc: called CC=7 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 12 | my ( $dev, $ctx, $spec ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 12 | ▶ | if ( $spec =~ /\A(?:([\w.-]+)@)?([\w.-]+):(.*)\z/ && $spec !~ m{\A/} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$spec =~ /\A(?:([\w.-]+)@)?([\w.-]+):(.*)\z/ and not $spec =~ m[\A/]
MC/DC50%1/2
$spec =~ /\A(?:([\w.-]+)@)?([\w.-]+):(.*)\z/ and not $spec =~ m[\A/]
$spec =~ /\A(?:([\w.-]+)@)?([\w.-]+):(.*)\z/
not $spec =~ m[\A/]
Truth table66%2/3
A and not(B)
A= $spec =~ /\A(?:([\w.-]+)@)?([\w.-]+):(.*)\z/B= not $spec =~ m[\A/]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | my ( $h, $p ) = ( $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | ▶ | my $d = ( $ctx->{state} || {} )->{$h}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$ctx{'state'} || {}
MC/DC0%0/1
$$ctx{'state'} || {}
$$ctx{'state'}
Truth table50%1/2
A
A= $$ctx{'state'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | ▶ | return ( undef, undef, "ssh: Could not resolve hostname $h: Name or service not known" ) unless ref $d eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | ▶ | return ( $d, length $p ? ( $p =~ m{\A/} ? $p : "/root/$p" ) : '/root' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 11 | return ( $dev, _abs($spec) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 19 | ▶ | sub _ex_match { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ex_match: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 19 | my ( $rel, $pats ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 19 | for my $p (@$pats) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | my $q = $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | my $anch = $q =~ s{\A/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | $q =~ s{/+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 4 | ( my $re = quotemeta $q ) =~ s/\\\*\\\*/.*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 4 | $re =~ s/\\\*/[^\/]*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | $re =~ s/\\\?/[^\/]/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | ▶ | return 1 if $anch ? $rel =~ /\A$re(?:\/|\z)/ : $rel =~ /(?:\A|\/)$re(?:\/|\z)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 18 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 6 | ▶ | sub rsync { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rsync: called CC=63 SCAR=50.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 6 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 6 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 6 | my ( %o, @ex, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 6 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 22 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ( $x =~ /\A--exclude=(.+)\z/ ) { push @ex, $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | elsif ( $x eq '--exclude' ) { push @ex, shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | ▶ | elsif ( $x eq '--delete' || $x =~ /\A--delete-(?:after|before|during|delay)\z/ ) { $o{delete} = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$x eq "--delete" or $x =~ /\A--delete-(?:after|before|during|delay)\z/
MC/DC50%1/2
$x eq "--delete" or $x =~ /\A--delete-(?:after|before|during|delay)\z/
$x eq "--delete"
$x =~ /\A--delete-(?:after|before|during|delay)\z/
Truth table66%2/3
A or B
A= $x eq "--delete"B= $x =~ /\A--delete-(?:after|before|during|delay)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | elsif ( $x eq '--delete-excluded' ) { $o{delete} = $o{delexcl} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | elsif ( $x eq '--dry-run' ) { $o{n} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | elsif ( $x eq '--archive' ) { $o{a} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | elsif ( $x eq '--recursive' ) { $o{r} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | elsif ( $x eq '-e' || $x eq '--rsh' ) { shift @a } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$x eq "-e" or $x eq "--rsh"
MC/DC0%0/2
$x eq "-e" or $x eq "--rsh"
$x eq "-e"
$x eq "--rsh"
Truth table33%1/3
A or B
A= $x eq "-e"B= $x eq "--rsh"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | elsif ( $x =~ /\A--/ ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 6 | elsif ( $x =~ /\A-([a-zA-Z]+)\z/ ) { $o{$_} = 1 for split //, $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 12 | else { push @args, $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | ▶ | return ( "rsync: [Receiver] error: need at least a source and a destination\nrsync error: syntax or usage error (code 1) at main.c(1678) [Receiver=3.2.7]", 0 ) unless @args >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 6 | my $dst_spec = pop @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 6 | ▶ | my $rec = $o{a} || $o{r}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$o{'a'} || $o{'r'}
MC/DC0%0/2
$o{'a'} || $o{'r'}
$o{'a'}
$o{'r'}
Truth table66%2/3
A || B
A= $o{'a'}B= $o{'r'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 6 | ▶ | my $keep = $o{a} || ( $o{p} && $o{o} && $o{g} && $o{t} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition41%5/12
$o{'a'} || $o{'p'} && $o{'o'} && $o{'g'} && $o{'t'}
$o{"p"} and $o{"o"} and $o{"g"} and $o{"t"}
$o{"p"} and $o{"o"} and $o{"g"}
$o{"p"} and $o{"o"}
MC/DC20%1/5
$o{'a'} || $o{'p'} && $o{'o'} && $o{'g'} && $o{'t'}
$o{'a'}
$o{"p"}
$o{"o"}
$o{"g"}
$o{"t"}
Truth table33%2/6
A || B and C and D and E
A= $o{'a'}B= $o{"p"}C= $o{"o"}D= $o{"g"}E= $o{"t"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 6 | my ( $dd, $dp, $de ) = _loc( $dev, $ctx, $dst_spec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 6 | ▶ | return ( "$de\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(231) [sender=3.2.7]", 0 ) if $de; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 6 | $dp =~ s{(?<=.)/+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 6 | my ( @out, %sent ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 6 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 6 | for my $s (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 6 | my $slash = $s =~ m{/\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 6 | my ( $sd, $sp, $se ) = _loc( $dev, $ctx, $s ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 6 | ▶ | return ( "$se\nrsync: connection unexpectedly closed (0 bytes received so far) [Receiver]\nrsync error: unexplained error (code 255) at io.c(231) [Receiver=3.2.7]", 0 ) if $se; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 6 | $sp =~ s{(?<=.)/+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 6 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 6 | ▶ | if ( _entry( $sd, $sp ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ( my $b = $sp ) =~ s{.*/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | ▶ | my $to = _L( '_is_dir', $dd, $dp ) || $dst_spec =~ m{/\z} || @args > 1 ? "$dp/$b" : $dp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
_L("_is_dir", $dd, $dp) or $dst_spec =~ m[/\z] or @args > 1
_L("_is_dir", $dd, $dp) or $dst_spec =~ m[/\z]
MC/DC0%0/3
_L("_is_dir", $dd, $dp) or $dst_spec =~ m[/\z] or @args > 1
_L("_is_dir", $dd, $dp)
$dst_spec =~ m[/\z]
@args > 1
Truth table25%1/4
A or B or C
A= _L("_is_dir", $dd, $dp)B= $dst_spec =~ m[/\z]C= @args > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | push @files, [ $sp, $to, $b ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | elsif ( _L( '_is_dir', $sd, $sp ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if ( !$rec ) { push @out, "skipping directory $sp"; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 5 | ( my $b = $sp ) =~ s{.*/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 5 | ▶ | my $root = $slash ? $dp : ( $dp eq '/' ? '' : $dp ) . "/$b"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 5 | for my $f ( _L( '_under', $sd, $sp ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 15 | my $rel = substr( $f, length($sp) + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 15 | ▶ | my $xrel = $slash ? $rel : "$b/$rel"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 15 | ▶ | next if _ex_match( $xrel, \@ex ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 14 | push @files, [ $f, "$root/$rel", $xrel ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 5 | ▶ | $sent{$root} = { map { $_->[1] => 1 } @files } if $o{delete}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 5 | ▶ | $sent{$root}{__root} = $slash ? '' : $b if $o{delete}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | push @out, "rsync: [sender] change_dir \"$sp\" failed: No such file or directory (2)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $err = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 6 | for my $f (@files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 15 | my ( $from, $to, $rel ) = @$f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 15 | ▶ | push @out, $rel if $o{v} || $o{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$o{"v"} or $o{"n"}
MC/DC100%2/2
$o{"v"} or $o{"n"}
$o{"v"}
$o{"n"}
Truth table100%3/3
A or B
A= $o{"v"}B= $o{"n"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 15 | ▶ | next if $o{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 12 | my $e = copy_entry( _entry( $sd, $from ), $keep ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ( !$keep && $o{p} ) { $e->{mode} = _entry( $sd, $from )->{mode} if ref _entry( $sd, $from ) eq 'HASH' && defined _entry( $sd, $from )->{mode} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
not $keep and $o{"p"}
ref _entry($sd, $from) eq "HASH" and defined _entry($sd, $from)->{"mode"}
MC/DC0%0/2
not $keep and $o{"p"}
not $keep
$o{"p"}
MC/DC0%0/2
ref _entry($sd, $from) eq "HASH" and defined _entry($sd, $from)->{"mode"}
ref _entry($sd, $from) eq "HASH"
defined _entry($sd, $from)->{"mode"}
Truth table66%2/3
not(A) and B
A= not $keepB= $o{"p"}
Truth table0%0/3
A and B
A= ref _entry($sd, $from) eq "HASH"B= defined _entry($sd, $from)->{"mode"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 12 | _put( $dd, $to, $e ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 6 | ▶ | if ( $o{delete} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | for my $root ( sort keys %sent ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 | my $have = $sent{$root}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | for my $f ( _L( '_under', $dd, $root ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 9 | ▶ | next if $have->{$f}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 4 | my $rel = substr( $f, length($root) + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 4 | ▶ | my $xrel = length $have->{__root} ? "$have->{__root}/$rel" : $rel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 4 | ▶ | next if !$o{delexcl} && _ex_match( $xrel, \@ex ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $o{"delexcl"} and _ex_match($xrel, \@ex)
MC/DC0%0/2
not $o{"delexcl"} and _ex_match($xrel, \@ex)
not $o{"delexcl"}
_ex_match($xrel, \@ex)
Truth table33%1/3
not(A) and B
A= not $o{"delexcl"}B= _ex_match($xrel, \@ex)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 4 | ▶ | push @out, "deleting $rel" if $o{v} || $o{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$o{"v"} or $o{"n"}
MC/DC50%1/2
$o{"v"} or $o{"n"}
$o{"v"}
$o{"n"}
Truth table66%2/3
A or B
A= $o{"v"}B= $o{"n"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 4 | ▶ | delete $dd->{files}{$f} unless $o{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | ▶ | unshift @out, 'sending incremental file list' if $o{v} || $o{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$o{"v"} or $o{"n"}
MC/DC100%2/2
$o{"v"} or $o{"n"}
$o{"v"}
$o{"n"}
Truth table100%3/3
A or B
A= $o{"v"}B= $o{"n"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 6 | ▶ | push @out, '', 'sent 1,024 bytes received 64 bytes 2,176.00 bytes/sec', 'total size is 4,096 speedup is 3.76' . ( $o{n} ? ' (DRY RUN)' : '' ) if $o{v} || $o{n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$o{"v"} or $o{"n"}
MC/DC100%2/2
$o{"v"} or $o{"n"}
$o{"v"}
$o{"n"}
Truth table100%3/3
A or B
A= $o{"v"}B= $o{"n"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 6 | ▶ | push @out, 'rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.2.7]' if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 6 | ▶ | return ( join( "\n", @out ), $err ? 0 : 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # --- restic -------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 23 | ▶ | sub _repo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_repo: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 23 | my ( $dev, $ctx, $spec ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 23 | my ( $d, $p ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 23 | ▶ | if ( $spec =~ /\Asftp:(?:[\w.-]+@)?([\w.-]+):(.+)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 21 | ▶ | $d = ( $ctx->{state} || {} )->{$1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$ctx{'state'} || {}
MC/DC0%0/1
$$ctx{'state'} || {}
$$ctx{'state'}
Truth table50%1/2
A
A= $$ctx{'state'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 21 | ▶ | return ( undef, "Fatal: unable to open repository at $spec: unable to start the sftp session, error: EOF" ) unless ref $d eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 21 | $p = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 2 | else { ( $d, $p ) = ( $dev, _abs($spec) ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 23 | $p =~ s{(?<=.)/+\z}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 23 | ▶ | my $r = ( $d->{restic_repos} || {} )->{$p}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$d{'restic_repos'} || {}
MC/DC0%0/1
$$d{'restic_repos'} || {}
$$d{'restic_repos'}
Truth table50%1/2
A
A= $$d{'restic_repos'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 23 | ▶ | return ( undef, "Fatal: repository does not exist: unable to open config file: stat $p/config: no such file or directory\nIs there a repository at the following location?\n$spec" ) unless $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 23 | return ($r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 3 | ▶ | sub _ts { my ($t) = @_; my @f = $t =~ /(\d+)/g; return Time::Local::timegm( $f[5] // 0, $f[4] // 0, $f[3] // 0, $f[2], $f[1] - 1, $f[0] ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ts: called CC=4 SCAR=15.2
Condition50%3/6
$f[5] // 0
$f[4] // 0
$f[3] // 0
MC/DC0%0/1
$f[5] // 0
$f[5]
MC/DC0%0/1
$f[4] // 0
$f[4]
MC/DC0%0/1
$f[3] // 0
$f[3]
Truth table50%1/2
A
A= $f[5]
Truth table50%1/2
A
A= $f[4]
Truth table50%1/2
A
A= $f[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # Filter --host/--path/--tag; a filter not given selects all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 17 | ▶ | sub _sel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sel: called CC=10 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 17 | my ( $snaps, %f ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 17 | ▶ | $f{$_} ||= [] for qw( host path tag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$f{$_} ||= []
MC/DC0%0/1
$f{$_} ||= []
$f{$_}
Truth table50%1/2
A
A= $f{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | return grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 17 | my $s = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 96 | ▶ | ( !@{ $f{host} } || grep { $_ eq $s->{host} } @{ $f{host} } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not @{$f{"path"};} or grep {my $p = $_;
grep {$_ eq $p;} @{$$s{"paths"} or [];};} @{$f{"path"};}
MC/DC50%1/2
not @{$f{"path"};} or grep {my $p = $_;
grep {$_ eq $p;} @{$$s{"paths"} or [];};} @{$f{"path"};}
not @{$f{"path"};}
grep {my $p = $_;
grep {$_ eq $p;} @{$$s{"paths"} or [];};} @{$f{"path"};}
Truth table66%2/3
not(A) or B
A= not @{$f{"path"};}B= grep {my $p = $_;
grep {$_ eq $p;} @{$$s{"paths"} or [];};} @{$f{"path"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | && ( !@{ $f{path} } || grep { my $p = $_; grep { $_ eq $p } @{ $s->{paths} || [] } } @{ $f{path} } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$$s{'paths'} || []
not @{$f{"tag"};} or grep {my $t = $_;
grep {$_ eq $t;} @{$$s{"tags"} or [];};} @{$f{"tag"};}
MC/DC0%0/1
$$s{'paths'} || []
$$s{'paths'}
MC/DC0%0/2
not @{$f{"tag"};} or grep {my $t = $_;
grep {$_ eq $t;} @{$$s{"tags"} or [];};} @{$f{"tag"};}
not @{$f{"tag"};}
grep {my $t = $_;
grep {$_ eq $t;} @{$$s{"tags"} or [];};} @{$f{"tag"};}
Truth table50%1/2
A
A= $$s{'paths'}
Truth table33%1/3
not(A) or B
A= not @{$f{"tag"};}B= grep {my $t = $_;
grep {$_ eq $t;} @{$$s{"tags"} or [];};} @{$f{"tag"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | && ( !@{ $f{tag} } || grep { my $t = $_; grep { $_ eq $t } @{ $s->{tags} || [] } } @{ $f{tag} } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition72%8/11
(!@{$f{'host'};} || grep({$_ eq $$s{'host'};} @{$f{'host'};})) && (!@{$f{'path'};} || grep({my $p = $_;
grep {$_ eq $p;} @{$$s{'paths'} or [];};} @{$f{'path'};})) && (!@{$f{'tag'};} || grep({my $t = $_;
grep {$_ eq $t;} @{$$s{'tags'} or [];};} @{$f{'tag'};}))
!@{$f{"host"};} || grep({$_ eq $$s{"host"};} @{$f{"host"};}) and !@{$f{"path"};} || grep({my $p = $_;
grep {$_ eq $p;} @{$$s{"paths"} or [];};} @{$f{"path"};})
not @{$f{"host"};} or grep {$_ eq $$s{"host"};} @{$f{"host"};}
$$s{'tags'} || []
MC/DC0%0/4
(!@{$f{'host'};} || grep({$_ eq $$s{'host'};} @{$f{'host'};})) && (!@{$f{'path'};} || grep({my $p = $_;
grep {$_ eq $p;} @{$$s{'paths'} or [];};} @{$f{'path'};})) && (!@{$f{'tag'};} || grep({my $t = $_;
grep {$_ eq $t;} @{$$s{'tags'} or [];};} @{$f{'tag'};}))
not @{$f{"host"};}
grep {$_ eq $$s{"host"};} @{$f{"host"};}
!@{$f{"path"};} || grep({my $p = $_;
grep {$_ eq $p;} @{$$s{"paths"} or [];};} @{$f{"path"};})
(!@{$f{'tag'};} || grep({my $t = $_;
grep {$_ eq $t;} @{$$s{'tags'} or [];};} @{$f{'tag'};}))
MC/DC0%0/1
$$s{'tags'} || []
$$s{'tags'}
Truth table14%1/7
not(A) or B and C && D
A= not @{$f{"host"};}B= grep {$_ eq $$s{"host"};} @{$f{"host"};}C= !@{$f{"path"};} || grep({my $p = $_;
grep {$_ eq $p;} @{$$s{"paths"} or [];};} @{$f{"path"};})D= (!@{$f{'tag'};} || grep({my $t = $_;
grep {$_ eq $t;} @{$$s{'tags'} or [];};} @{$f{'tag'};}))
Truth table0%0/2
A
A= $$s{'tags'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } @$snaps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 10 | ▶ | sub _find_snap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_snap: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 10 | my ( $r, $id, %f ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 10 | ▶ | my @s = sort { $a->{time} cmp $b->{time} } _sel( $r->{snapshots} || [], %f ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$r{'snapshots'} || []
MC/DC0%0/1
$$r{'snapshots'} || []
$$r{'snapshots'}
Truth table50%1/2
A
A= $$r{'snapshots'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 10 | ▶ | return $s[-1] if $id eq 'latest'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 6 | ▶ | my @m = grep { index( $_->{id}, $id ) == 0 } @{ $r->{snapshots} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$r{'snapshots'} || []
MC/DC0%0/1
$$r{'snapshots'} || []
$$r{'snapshots'}
Truth table50%1/2
A
A= $$r{'snapshots'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 6 | ▶ | return @m == 1 ? $m[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 34 | ▶ | sub _snap_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_snap_line: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 34 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 34 | ▶ | my @p = @{ $s->{paths} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$s{'paths'} || []
MC/DC100%1/1
$$s{'paths'} || []
$$s{'paths'}
Truth table100%2/2
A
A= $$s{'paths'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 34 | ▶ | my @l = sprintf( '%-9s %-20s %-11s %-11s %s', substr( $s->{id}, 0, 8 ), $s->{time}, $s->{host}, join( ',', @{ $s->{tags} || [] } ), shift(@p) // '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$$s{'tags'} || []
shift @p // ""
MC/DC0%0/1
$$s{'tags'} || []
$$s{'tags'}
MC/DC100%1/1
shift @p // ""
shift @p
Truth table50%1/2
A
A= $$s{'tags'}
Truth table100%2/2
A
A= shift @p
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | push @l, map { ( ' ' x 54 ) . $_ } @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 34 | return @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # Aufbewahrung wie restic (internal/restic/snapshot_policy.go): neueste zuerst | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 6 | ▶ | sub _policy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_policy: called CC=9 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 6 | my ( $list, $keep ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 6 | my @s = sort { $b->{time} cmp $a->{time} } @$list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | my %fn = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 4 | ▶ | last => sub { $_[0]{id} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | hourly => sub { POSIX::strftime( '%Y%m%d%H', gmtime _ts( $_[0]{time} ) ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | ▶ | daily => sub { POSIX::strftime( '%Y%m%d', gmtime _ts( $_[0]{time} ) ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | weekly => sub { POSIX::strftime( '%G%V', gmtime _ts( $_[0]{time} ) ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | monthly => sub { POSIX::strftime( '%Y%m', gmtime _ts( $_[0]{time} ) ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | yearly => sub { POSIX::strftime( '%Y', gmtime _ts( $_[0]{time} ) ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 5 | my %cnt = map { $_ => $keep->{$_} } grep { defined $keep->{$_} } keys %fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 5 | my %last = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 5 | my ( @k, @r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 5 | ▶ | return ( \@s, [] ) unless %cnt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 5 | for my $sn (@s) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 17 | my $kp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 17 | for my $rule ( sort keys %cnt ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 17 | ▶ | next unless $cnt{$rule}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 7 | my $v = $fn{$rule}->($sn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 7 | ▶ | next if defined $last{$rule} && $last{$rule} eq $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $last{$rule} and $last{$rule} eq $v
MC/DC100%2/2
defined $last{$rule} and $last{$rule} eq $v
defined $last{$rule}
$last{$rule} eq $v
Truth table100%3/3
A and B
A= defined $last{$rule}B= $last{$rule} eq $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 6 | $last{$rule} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 6 | ▶ | $cnt{$rule}-- if $cnt{$rule} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 6 | $kp = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 17 | ▶ | push @{ $kp ? \@k : \@r }, $sn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 5 | return ( \@k, \@r ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 23 | ▶ | sub restic { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
restic: called CC=96 SCAR=53.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 23 | my ( $dev, $av, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 23 | my @a = @$av; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 23 | ▶ | my %env = %{ $Langertha::Holmgang::Sim::Linux::SHENV || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$Langertha::Holmgang::Sim::Linux::SHENV || {}
MC/DC0%0/1
$Langertha::Holmgang::Sim::Linux::SHENV || {}
$Langertha::Holmgang::Sim::Linux::SHENV
Truth table50%1/2
A
A= $Langertha::Holmgang::Sim::Linux::SHENV
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 23 | my ( $repo, $pwf, $cmd, %f, %keep, @rest, %o, @inc, @exc ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 23 | $f{$_} = [] for qw( host path tag ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 23 | $repo = $env{RESTIC_REPOSITORY}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 23 | $pwf = $env{RESTIC_PASSWORD_FILE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 23 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 93 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 93 | ▶ | my $val = sub { $x =~ /\A--[\w-]+=(.*)\z/ ? $1 : shift @a }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 93 | ▶ | if ( $x =~ /\A(?:-r|--repo)(?:=|\z)/ ) { $repo = $val->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 21 | elsif ( $x =~ /\A(?:-p|--password-file)(?:=|\z)/ ) { $pwf = $val->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 5 | elsif ( $x =~ /\A--(host|path|tag)(?:=|\z)/ ) { my $k = $1; push @{ $f{$k} }, split /,/, $val->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | elsif ( $x =~ /\A--keep-(last|hourly|daily|weekly|monthly|yearly)(?:=|\z)/ ) { my $k = $1; $keep{$k} = $val->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | elsif ( $x =~ /\A(?:-t|--target)(?:=|\z)/ ) { $o{target} = $val->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 1 | elsif ( $x =~ /\A(?:-i|--include)(?:=|\z)/ ) { push @inc, $val->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | elsif ( $x =~ /\A(?:-e|--exclude)(?:=|\z)/ ) { push @exc, $val->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | elsif ( $x =~ /\A--group-by(?:=|\z)/ ) { $o{group} = $val->() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | elsif ( $x eq '--prune' ) { $o{prune} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | elsif ( $x eq '--dry-run' || $x eq '-n' ) { $o{dry} = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$x eq "--dry-run" or $x eq "-n"
MC/DC0%0/2
$x eq "--dry-run" or $x eq "-n"
$x eq "--dry-run"
$x eq "-n"
Truth table33%1/3
A or B
A= $x eq "--dry-run"B= $x eq "-n"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | elsif ( $x eq '--remove-all' ) { $o{all} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | elsif ( $x =~ /\A-/ ) { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 23 | elsif ( !defined $cmd ) { $cmd = $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 14 | else { push @rest, $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 23 | ▶ | return ( "restic is a backup program which allows saving multiple revisions of files and\ndirectories in an encrypted repository stored on different backends.\n\nUsage:\n restic [command]", 0 ) unless defined $cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 23 | ▶ | return ( 'restic 0.14.0 compiled with go1.19.8 on linux/amd64', 1 ) if $cmd eq 'version'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 23 | ▶ | return ( 'Fatal: Please specify repository location (-r or --repository-file)', 0 ) unless defined $repo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 23 | my ( $r, $e ) = _repo( $dev, $ctx, $repo ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 23 | ▶ | return ( $e, 0 ) unless $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 23 | ▶ | if ( !defined $pwf || _abs($pwf) ne ( $r->{password_file} // '' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
not defined $pwf or _abs($pwf) ne ($$r{"password_file"} // "")
$$r{"password_file"} // ""
MC/DC50%1/2
not defined $pwf or _abs($pwf) ne ($$r{"password_file"} // "")
not defined $pwf
_abs($pwf) ne ($$r{"password_file"} // "")
MC/DC0%0/1
$$r{"password_file"} // ""
$$r{"password_file"}
Truth table66%2/3
not(A) or B
A= not defined $pwfB= _abs($pwf) ne ($$r{"password_file"} // "")
Truth table50%1/2
A
A= $$r{"password_file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | ▶ | return ( "Fatal: Load(<password>): open " . _abs($pwf) . ": no such file or directory", 0 ) if defined $pwf && !_entry( $dev, _abs($pwf) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $pwf and not _entry($dev, _abs($pwf))
MC/DC0%0/2
defined $pwf and not _entry($dev, _abs($pwf))
defined $pwf
not _entry($dev, _abs($pwf))
Truth table33%1/3
A and not(B)
A= defined $pwfB= not _entry($dev, _abs($pwf))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | ▶ | return ( "Fatal: an empty password is not allowed by default. Pass the flag `--insecure-no-password` to restic to disable this check", 0 ) unless defined $pwf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | return ( "Fatal: wrong password or no key found", 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 22 | ▶ | if ( $r->{lock} && $cmd !~ /\A(?:unlock|snapshots|ls|dump|cat|stats)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$r{"lock"} and not $cmd =~ /\A(?:unlock|snapshots|ls|dump|cat|stats)\z/
MC/DC100%2/2
$$r{"lock"} and not $cmd =~ /\A(?:unlock|snapshots|ls|dump|cat|stats)\z/
$$r{"lock"}
not $cmd =~ /\A(?:unlock|snapshots|ls|dump|cat|stats)\z/
Truth table100%3/3
A and not(B)
A= $$r{"lock"}B= not $cmd =~ /\A(?:unlock|snapshots|ls|dump|cat|stats)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | my $l = $r->{lock}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | return ( "repository is already locked by PID $l->{pid} on $l->{host} by root (UID 0, GID 0)\nlock was created at $l->{time} (12h29m55s ago)\nstorage ID 8a1b2c3d\nthe `unlock` command can be used to remove stale locks", 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 21 | ▶ | my @snaps = @{ $r->{snapshots} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$r{'snapshots'} || []
MC/DC0%0/1
$$r{'snapshots'} || []
$$r{'snapshots'}
Truth table50%1/2
A
A= $$r{'snapshots'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 21 | ▶ | if ( $cmd eq 'snapshots' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 4 | my @s = sort { $a->{time} cmp $b->{time} } _sel( \@snaps, %f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 4 | my $hr = '-' x 74; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 4 | return ( join( "\n", sprintf( '%-9s %-20s %-11s %-11s %s', 'ID', 'Time', 'Host', 'Tags', 'Paths' ), $hr, ( map { _snap_line($_) } @s ), $hr, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | scalar(@s) . ' snapshots' ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 17 | ▶ | if ( $cmd eq 'unlock' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | ▶ | delete $r->{lock} if $r->{lock}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 1 | return ( 'successfully removed 1 locks', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ( $cmd eq 'check' ) { return ( "using temporary cache in /tmp/restic-check-cache-1\ncreated new cache in /tmp/restic-check-cache-1\nload indexes\ncheck all packs\ncheck snapshots, trees and blobs\nno errors were found", 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 16 | ▶ | if ( $cmd eq 'stats' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | return ( "repository 3c1f2e9a opened (version 2, compression level auto)\nscanning...\nStats in restore-size mode:\n Snapshots processed: " . scalar(@snaps) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | . "\n Total File Count: " . ( 0 + map { keys %{ $_->{files} || {} } } @snaps ) . "\n Total Size: $r->{size}", 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$_{'files'} || {}
MC/DC0%0/1
$$_{'files'} || {}
$$_{'files'}
Truth table0%0/2
A
A= $$_{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 16 | ▶ | if ( $cmd eq 'ls' || $cmd eq 'dump' || $cmd eq 'restore' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$cmd eq "ls" or $cmd eq "dump" or $cmd eq "restore"
$cmd eq "ls" or $cmd eq "dump"
MC/DC100%3/3
$cmd eq "ls" or $cmd eq "dump" or $cmd eq "restore"
$cmd eq "ls"
$cmd eq "dump"
$cmd eq "restore"
Truth table100%4/4
A or B or C
A= $cmd eq "ls"B= $cmd eq "dump"C= $cmd eq "restore"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 7 | ▶ | my $id = shift(@rest) // return ( "Fatal: no snapshot ID specified", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @rest // (return "Fatal: no snapshot ID specified", 0)
MC/DC0%0/1
shift @rest // (return "Fatal: no snapshot ID specified", 0)
shift @rest
Truth table50%1/2
A
A= shift @rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 7 | ▶ | my $s = _find_snap( $r, $id, %f ) or return ( "Fatal: invalid id \"$id\": no matching ID found for prefix \"$id\"", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 7 | ▶ | my %files = %{ $s->{files} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$s{'files'} || {}
MC/DC0%0/1
$$s{'files'} || {}
$$s{'files'}
Truth table50%1/2
A
A= $$s{'files'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 7 | ▶ | if ( $cmd eq 'ls' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | my ($under) = @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 3 | ▶ | my @n = sort grep { !defined $under || $_ eq $under || index( $_, "$under/" ) == 0 } keys %files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
!defined($under) || $_ eq $under || index($_, "$under/") == 0
not defined $under or $_ eq $under
MC/DC0%0/3
!defined($under) || $_ eq $under || index($_, "$under/") == 0
not defined $under
$_ eq $under
index($_, "$under/") == 0
Truth table25%1/4
not(A) or B || C
A= not defined $underB= $_ eq $underC= index($_, "$under/") == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | ▶ | return ( join( "\n", "snapshot " . substr( $s->{id}, 0, 8 ) . " of [@{ $s->{paths} || [] }] at $s->{time}):", @n ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$s{'paths'} || []
MC/DC100%1/1
$$s{'paths'} || []
$$s{'paths'}
Truth table100%2/2
A
A= $$s{'paths'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 4 | ▶ | if ( $cmd eq 'dump' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 1 | ▶ | my $p = shift(@rest) // return ( 'Fatal: no file and no snapshot ID specified', 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @rest // (return "Fatal: no file and no snapshot ID specified", 0)
MC/DC0%0/1
shift @rest // (return "Fatal: no file and no snapshot ID specified", 0)
shift @rest
Truth table50%1/2
A
A= shift @rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | ▶ | my $fe = $files{$p} or return ( "Fatal: cannot dump file: path \"$p\" not found in snapshot", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | ▶ | return ( ( ref $fe ? $fe->{content} // '' : $fe ) =~ s/\n\z//r, 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$fe{"content"} // ""
MC/DC0%0/1
$$fe{"content"} // ""
$$fe{"content"}
Truth table50%1/2
A
A= $$fe{"content"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 3 | ▶ | return ( 'Fatal: Please specify a directory to restore to (--target)', 0 ) unless defined $o{target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 3 | my $tg = _abs( $o{target} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 1 | ▶ | my $match = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 1 | my ( $p, $pats ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | for my $q (@$pats) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | ( my $re = quotemeta( $q =~ s{/+\z}{}r ) ) =~ s/\\\*/[^\/]*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 1 | ▶ | return 1 if $p =~ /\A$re(?:\/|\z)/ || $p =~ /(?:\A|\/)$re\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$p =~ m[\A$re(?:/|\z)] or $p =~ m[(?:\A|/)$re\z]
MC/DC0%0/2
$p =~ m[\A$re(?:/|\z)] or $p =~ m[(?:\A|/)$re\z]
$p =~ m[\A$re(?:/|\z)]
$p =~ m[(?:\A|/)$re\z]
Truth table33%1/3
A or B
A= $p =~ m[\A$re(?:/|\z)]B= $p =~ m[(?:\A|/)$re\z]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 3 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 3 | for my $p ( sort keys %files ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 3 | ▶ | next if @inc && !$match->( $p, \@inc ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@inc and not &$match($p, \@inc)
MC/DC0%0/2
@inc and not &$match($p, \@inc)
@inc
not &$match($p, \@inc)
Truth table66%2/3
A and not(B)
A= @incB= not &$match($p, \@inc)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 3 | ▶ | next if @exc && $match->( $p, \@exc ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@exc and &$match($p, \@exc)
MC/DC0%0/2
@exc and &$match($p, \@exc)
@exc
&$match($p, \@exc)
Truth table33%1/3
A and B
A= @excB= &$match($p, \@exc)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 3 | ▶ | _put( $dev, ( $tg eq '/' ? '' : $tg ) . $p, copy_entry( $files{$p}, 1 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 3 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 3 | ▶ | return ( "Fatal: there are no files to restore", 0 ) if !$n && @inc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $n and @inc
MC/DC0%0/2
not $n and @inc
not $n
@inc
Truth table33%1/3
not(A) and B
A= not $nB= @inc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 3 | ▶ | return ( "repository 3c1f2e9a opened (version 2, compression level auto)\nrestoring <Snapshot " . substr( $s->{id}, 0, 8 ) . " of [@{ $s->{paths} || [] }] at $s->{time} by root\@$s->{host}> to $tg\nSummary: Restored $n files/dirs", 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$s{'paths'} || []
MC/DC100%1/1
$$s{'paths'} || []
$$s{'paths'}
Truth table100%2/2
A
A= $$s{'paths'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 9 | ▶ | if ( $cmd eq 'forget' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 7 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | my %gone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 7 | ▶ | if (@rest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 4 | for my $id (@rest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 4 | ▶ | my $s = _find_snap( $r, $id, %f ) or return ( "Fatal: invalid id \"$id\": no matching ID found for prefix \"$id\"", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 3 | $gone{ $s->{id} } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 3 | push @l, "removed snapshot " . substr( $s->{id}, 0, 8 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 3 | ▶ | return ( 'no policy was specified, no snapshots will be removed', 1 ) unless %keep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 3 | ▶ | for my $k ( values %keep ) { return ( "Fatal: invalid argument \"$k\"", 0 ) unless $k =~ /\A\d+\z/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 3 | ▶ | my @by = split /,/, $o{group} // 'host,paths'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$o{"group"} // "host,paths"
MC/DC0%0/1
$o{"group"} // "host,paths"
$o{"group"}
Truth table50%1/2
A
A= $o{"group"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 3 | my %grp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | for my $s ( _sel( \@snaps, %f ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | my $key = join '|', map { $_ eq 'host' ? $s->{host} : $_ eq 'paths' ? join( ',', sort @{ $s->{paths} || [] } ) : $_ eq 'tags' ? join( ',', sort @{ $s->{tags} || [] } ) : '' } @by; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition50%2/4
$$s{'paths'} || []
$$s{'tags'} || []
MC/DC100%1/1
$$s{'paths'} || []
$$s{'paths'}
MC/DC0%0/1
$$s{'tags'} || []
$$s{'tags'}
Truth table100%2/2
A
A= $$s{'paths'}
Truth table0%0/2
A
A= $$s{'tags'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 17 | push @{ $grp{$key} }, $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 3 | push @l, 'Applying Policy: keep ' . join( ', ', map {"$keep{$_} $_ snapshots"} sort keys %keep ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 3 | for my $g ( sort keys %grp ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 5 | my ( $k, $rm ) = _policy( $grp{$g}, \%keep ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 10 | push @l, "snapshots for (" . join( ', ', map { my $i = $_; $i } @by ) . " [$g]):", "keep " . scalar(@$k) . ' snapshots:', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 6 | ▶ | ( map { _snap_line($_) } sort { $a->{time} cmp $b->{time} } @$k ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 5 | ( @$rm ? ( 'remove ' . scalar(@$rm) . ' snapshots:', map { _snap_line($_) } sort { $a->{time} cmp $b->{time} } @$rm ) : () ), ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 5 | $gone{ $_->{id} } = 1 for @$rm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 6 | ▶ | unless ( $o{dry} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 6 | my $free = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 6 | ▶ | $free += _L( '_bytes', $_->{unique} // 0 ) for grep { $gone{ $_->{id} } } @snaps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$_{"unique"} // 0
MC/DC100%1/1
$$_{"unique"} // 0
$$_{"unique"}
Truth table100%2/2
A
A= $$_{"unique"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 6 | $r->{snapshots} = [ grep { !$gone{ $_->{id} } } @snaps ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 6 | ▶ | $r->{prunable} = _L( '_human', _L( '_bytes', $r->{prunable} // 0 ) + $free ) if $free; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$$r{"prunable"} // 0
MC/DC100%1/1
$$r{"prunable"} // 0
$$r{"prunable"}
Truth table100%2/2
A
A= $$r{"prunable"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 6 | ▶ | push @l, _prune($r) if $o{prune}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 6 | return ( join( "\n", @l ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 2 | ▶ | if ( $cmd eq 'prune' ) { return ( _prune($r), 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 1 | ▶ | if ( $cmd eq 'backup' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 1 | ▶ | return ( 'Fatal: nothing to backup, please specify source files/dirs', 0 ) unless @rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | my %files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 1 | my @paths = map { _abs($_) =~ s{(?<=.)/+\z}{}r } @rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | for my $p (@paths) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | ▶ | my @fs = _entry( $dev, $p ) ? ($p) : _L( '_under', $dev, $p ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | ▶ | return ( "Fatal: unable to save snapshot: lstat $p: no such file or directory", 0 ) unless @fs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 1 | $files{$_} = copy_entry( _entry( $dev, $_ ), 1 ) for @fs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | for my $x (@exc) { delete $files{$_} for grep { index( $_, $x =~ s{/+\z}{}r ) == 0 } keys %files } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | my $id = substr( Digest::SHA::sha256_hex( JSON::MaybeXS->new( canonical => 1 )->encode( [ \%files, scalar @snaps ] ) ), 0, 8 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | ▶ | push @{ $r->{snapshots} }, { id => $id, time => '2026-10-20 12:00:00', host => $dev->{hostname} // $ctx->{host}, paths => [ sort @paths ], tags => [], files => \%files }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$$dev{"hostname"} // $$ctx{"host"}
MC/DC0%0/2
$$dev{"hostname"} // $$ctx{"host"}
$$dev{"hostname"}
$$ctx{"host"}
Truth table33%1/3
A // B
A= $$dev{"hostname"}B= $$ctx{"host"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 1 | ▶ | return ( "repository 3c1f2e9a opened (version 2, compression level auto)\nusing parent snapshot " . ( @snaps ? substr( $snaps[-1]{id}, 0, 8 ) : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | . "\n\nFiles: " . scalar( keys %files ) . " new, 0 changed, 0 unmodified\nAdded to the repository: 12.204 MiB\n\nsnapshot $id saved", 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | return ( "Error: unknown command \"$cmd\" for \"restic\"\nRun 'restic --help' for usage.", 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 2 | ▶ | sub _prune { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prune: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 2 | my ($r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | ▶ | my $p = _L( '_bytes', $r->{prunable} // 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$r{"prunable"} // 0
MC/DC0%0/1
$$r{"prunable"} // 0
$$r{"prunable"}
Truth table50%1/2
A
A= $$r{"prunable"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 2 | ▶ | my $s = _L( '_bytes', $r->{size} // 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$r{"size"} // 0
MC/DC0%0/1
$$r{"size"} // 0
$$r{"size"}
Truth table50%1/2
A
A= $$r{"size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | ▶ | $r->{size} = _L( '_human', $s - $p > 0 ? $s - $p : 0 ) if $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | delete $r->{prunable}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 2 | return "loading indexes...\nfinding data that is still in use for snapshots\nsearching used packs...\ncollecting packs for deletion and repacking\nto delete: " . _L( '_human', $p ) . "\ndone"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||