| 1 | # Copyright (c) 2025-2026 Philipp Schafft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Module for interacting with file stores | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package File::FStore; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use DBI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Data::Identifier; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Data::Identifier::Generate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use File::FStore::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use parent qw(Data::Identifier::Interface::Known Data::Identifier::Interface::Userdata Data::Identifier::Interface::Subobjects); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | our $VERSION = v0.08; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | DEFAULT_LINK_STYLE => '1-level', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | DEFAULT_STORE_STYLE => '1-level-contentise', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | my %_types = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | db => 'Data::TagDB', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | extractor => 'Data::URIID', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | fii => 'File::Information', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 40 | our %_valid_digests = map {$_ => int((/^[^-]+-[^-]-([0-9]+)$/)[0]/4)} ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | qw(md-5-128 sha-1-160), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | (map {'sha-2-'.$_, 'sha-3-'.$_} 224, 256, 384, 512), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | our %_valid_link_styles = map {$_ => 1} qw(none 1-level 2-level); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 4 | our %_valid_store_styles = map {$_ => 1} qw(1-level-contentise 2-level-contentise); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | my %_flat_settings = map {$_ => $_} qw(link_style store_style); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | our %_ni_hashes = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'sha-2-256' => 'sha-256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'sha-2-384' => 'sha-384', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'sha-2-512' => 'sha-512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'sha-3-224' => 'sha3-224', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'sha-3-256' => 'sha3-256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'sha-3-384' => 'sha3-384', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'sha-3-512' => 'sha3-512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | my %_ni_hashes_reverse = map {$_ni_hashes{$_} => $_} keys %_ni_hashes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=15 SCAR=28.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | my $path = delete($opts{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | ▶ | my $digests = delete($opts{digests}) // [keys %_valid_digests]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{"digests"} // [keys %File::FStore::_valid_digests]
MC/DC0%0/1
delete $opts{"digests"} // [keys %File::FStore::_valid_digests]
delete $opts{"digests"}
Truth table50%1/2
A
A= delete $opts{"digests"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | my %extra; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | my $dbh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | foreach my $key (keys(%_types), qw(weak)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | my $v = delete $opts{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | ▶ | $extra{$key} = $v if defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | ▶ | $digests = [split(/\s*,\s*|\s+/, $digests)] unless ref $digests; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | foreach my $digest (@{$digests}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 20 | ▶ | croak 'Invalid digest: '.$digest unless defined $_valid_digests{$digest}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | mkdir($path) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | mkdir(File::Spec->catdir($path, qw(v2))) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | mkdir(File::Spec->catdir($path, qw(v2 store))) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | mkdir(File::Spec->catdir($path, qw(v2 by))) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | foreach my $digest (@{$digests}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 20 | ▶ | mkdir(File::Spec->catdir($path, qw(v2 by), $digest)) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | $dbh = DBI->connect('dbi:SQLite:dbname='.File::Spec->catfile($path => v2 => store => 'db.sqlite'), undef, undef, { RaiseError => 1, PrintError => undef }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | #@inject SQLITE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $dbh->do($_) for split /;/, << 'SQL'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | CREATE TABLE file ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | id INTEGER NOT NULL UNIQUE PRIMARY KEY AUTOINCREMENT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | filename VARCHAR(128) NOT NULL UNIQUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | CREATE TABLE file_properties ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | file INTEGER NOT NULL REFERENCES file (id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | key VARCHAR(64) NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | value VARCHAR(128) NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | UNIQUE (file, key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | CREATE TABLE file_hash ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | file INTEGER NOT NULL REFERENCES file (id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | algo VARCHAR(32) NOT NULL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | hash VARCHAR(255) NOT NULL UNIQUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | UNIQUE (file, algo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | SQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | $dbh->disconnect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | return $pkg->new(path => $path, %extra); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | #@returns __PACKAGE__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=19 SCAR=41.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | ▶ | my $path = delete $opts{path} // croak 'No path given'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{"path"} // croak("No path given")
MC/DC0%0/1
delete $opts{"path"} // croak("No path given")
delete $opts{"path"}
Truth table50%1/2
A
A= delete $opts{"path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | my $weak = delete $opts{weak}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | my @used_digests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | my @used_digests_ni; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | used_digests => \@used_digests, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | used_digests_ni => \@used_digests_ni, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | transaction_count => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | link_style => DEFAULT_LINK_STYLE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | store_style => DEFAULT_STORE_STYLE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | }, $pkg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | foreach my $key (keys %_types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 12 | my $v = delete $opts{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 12 | ▶ | next unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->so_attach($key => $v, weak => $weak); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | ▶ | if (defined(my $link_style = delete $opts{link_style})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $link_style = DEFAULT_LINK_STYLE if $link_style eq 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | croak 'Not a valid link style: '.$link_style unless defined $_valid_link_styles{$link_style}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->{link_style} = $link_style; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | ▶ | if (defined(my $store_style = delete $opts{store_style})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $store_style = DEFAULT_STORE_STYLE if $store_style eq 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | croak 'Not a valid store style: '.$store_style unless defined $_valid_store_styles{$store_style}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self->{store_style} = $store_style; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | ▶ | opendir(my $dir, $self->_directory(v2 => 'by')) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | while (defined(my $ent = readdir($dir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 48 | ▶ | next if $ent =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 40 | ▶ | croak 'Invalid store, unsupported/invalid digest used: '.$ent unless $_valid_digests{$ent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 40 | push(@used_digests, $ent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | closedir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | ▶ | if (opendir(my $dir, $self->_directory(v2 => 'ni'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | while (defined(my $ent = readdir($dir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | next if $ent =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | push(@used_digests_ni, $_ni_hashes_reverse{$ent} // next); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ni_hashes_reverse{$ent} // (next)
MC/DC0%0/1
$_ni_hashes_reverse{$ent} // (next)
$_ni_hashes_reverse{$ent}
Truth table0%0/2
A
A= $_ni_hashes_reverse{$ent}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | closedir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | $self->{dbh} = DBI->connect('dbi:SQLite:dbname='.$self->_file(v2 => store => 'db.sqlite'), undef, undef, { RaiseError => 1, PrintError => undef }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | $self->DESTROY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 9 | ▶ | sub setting { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setting: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 9 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 9 | ▶ | croak 'No key given' unless defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 9 | ▶ | if (defined(my $flatkey = $_flat_settings{$key})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 9 | return $self->{$flatkey}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | croak 'Unknown key: '.$key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 11 | ▶ | sub in_transaction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
in_transaction: called CC=12 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 11 | my ($self, $type, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 11 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 11 | ▶ | croak 'Bad transaction type' unless $type eq 'ro' || $type eq 'rw'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type eq "ro" or $type eq "rw"
MC/DC0%0/2
$type eq "ro" or $type eq "rw"
$type eq "ro"
$type eq "rw"
Truth table66%2/3
A or B
A= $type eq "ro"B= $type eq "rw"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 11 | ▶ | return undef if defined $self->{transaction_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 11 | ▶ | if ($self->{transaction_count}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | ▶ | if ($type ne 'ro' && $type ne $self->{transaction_type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type ne "ro" and $type ne $self->{"transaction_type"}
MC/DC0%0/2
$type ne "ro" and $type ne $self->{"transaction_type"}
$type ne "ro"
$type ne $self->{"transaction_type"}
Truth table33%1/3
A and B
A= $type ne "ro"B= $type ne $self->{"transaction_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | croak 'Invalid inner transaction type '.$type.' within outer '.$self->{transaction_type}.' transaction'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6 | $self->{dbh}->begin_work; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | $self->{transaction_type} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | $self->{transaction_error} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 11 | $self->{transaction_count}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 11 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 11 | $code->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 11 | ▶ | $error = $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 11 | ▶ | $self->{transaction_error} //= $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"transaction_error"} //= $error
MC/DC0%0/2
$self->{"transaction_error"} //= $error
$self->{"transaction_error"}
$error
Truth table33%1/3
A //= B
A= $self->{"transaction_error"}B= $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 11 | $self->{transaction_count}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 11 | ▶ | unless ($self->{transaction_count}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | ▶ | if (defined $self->{transaction_error}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->{dbh}->rollback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 6 | $self->{dbh}->commit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 11 | ▶ | croak $error if defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 17 | ▶ | sub query { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query: called CC=46 SCAR=51.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | my ($self, @query) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 17 | my %fields = (properties => {}, digests => {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 17 | my $limit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | my $offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 17 | my $order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 17 | my @q; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 17 | my @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 17 | ▶ | while (defined(my $cmd = shift(@query))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 17 | ▶ | $cmd = 'digests' if $cmd eq 'hashes'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 17 | ▶ | if ($cmd eq 'properties' || $cmd eq 'digests') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
Condition100%3/3
$cmd eq "properties" or $cmd eq "digests"
MC/DC100%2/2
$cmd eq "properties" or $cmd eq "digests"
$cmd eq "properties"
$cmd eq "digests"
Truth table100%3/3
A or B
A= $cmd eq "properties"B= $cmd eq "digests"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 12 | ▶ | my $n = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table50%1/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 12 | my $t = $fields{$cmd}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 12 | ▶ | if (ref($n)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | %{$t} = (%{$t}, %{$n}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 12 | ▶ | my $v = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table50%1/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 12 | $t->{$n} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } elsif ($cmd eq 'all') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | push(@q, 'SELECT id FROM file'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } elsif ($cmd eq 'limit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $limit = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table0%0/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } elsif ($cmd eq 'offset') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | $offset = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table0%0/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } elsif ($cmd eq 'order') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | $order = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table0%0/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $order = uc($order); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | croak 'Bad order' if $order ne 'ASC' && $order ne 'DESC'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$order ne "ASC" and $order ne "DESC"
MC/DC0%0/2
$order ne "ASC" and $order ne "DESC"
$order ne "ASC"
$order ne "DESC"
Truth table0%0/3
A and B
A= $order ne "ASC"B= $order ne "DESC"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } elsif ($cmd eq 'min_size') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | my $v = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table0%0/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | push(@q, 'SELECT file AS id FROM file_properties WHERE key = \'size\' AND CAST(value AS BIG INTEGER) >= ?'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | push(@p, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } elsif ($cmd eq 'max_size') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | my $v = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table0%0/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | push(@q, 'SELECT file AS id FROM file_properties WHERE key = \'size\' AND CAST(value AS BIG INTEGER) <= ?'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | push(@p, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } elsif ($cmd eq 'dbname') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 4 | ▶ | my $v = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table50%1/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 4 | ▶ | $v = [$v] unless ref $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | croak 'Empty list for dbname' unless scalar(@{$v}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 4 | push(@q, 'SELECT id FROM file WHERE '.$self->_placeholders(filename => $v)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | push(@p, @{$v}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } elsif ($cmd eq 'ise') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | ▶ | my $v = shift(@query) // croak 'Incomplete query'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @query // croak("Incomplete query")
MC/DC0%0/1
shift @query // croak("Incomplete query")
shift @query
Truth table50%1/2
A
A= shift @query
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | if (ref $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if (eval {$v->isa('Data::Identifier::Cloudlet')}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $v = [$v->entries]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | } elsif (eval {$v->can('ise')}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $v = [$v]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $v = [$v]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | ▶ | croak 'Empty list for ise' unless scalar(@{$v}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | foreach my $s (@{$v}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | ▶ | $s = $s->ise if ref $s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | push(@q, 'SELECT file AS id FROM file_properties WHERE key IN (\'contentise\', \'inodeise\') AND '.$self->_placeholders(value => $v)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | push(@p, @{$v}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | croak 'Invalid query command: '.$cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 17 | foreach my $digest (keys %{$fields{digests}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 10 | my $v = $fields{digests}{$digest}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 10 | ▶ | $v = [$v] unless ref($v) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 10 | unshift(@q, 'SELECT file AS id FROM file_hash WHERE algo = ? AND '.$self->_placeholders(hash => $v)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 10 | unshift(@p, $digest, @{$v}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 17 | foreach my $property (keys %{$fields{properties}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | my $v = $fields{properties}{$property}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | $v = [$v] unless ref($v) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | push(@q, 'SELECT file AS id FROM file_properties WHERE key = ? AND '.$self->_placeholders(value => $v)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | push(@p, $property, @{$v}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 17 | ▶ | unless (scalar @q) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | croak 'No filter given'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 17 | my $q = join(' INTERSECT ', @q); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 17 | my $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | my @result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 17 | ▶ | if (defined $order) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $q .= ' ORDER BY id '.$order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 17 | ▶ | $limit = 2 unless wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 17 | ▶ | if (defined $limit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 14 | $q .= ' LIMIT ?'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 14 | push(@p, $limit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 17 | ▶ | if (defined $offset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $q .= ' OFFSET ?'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | push(@p, $offset); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 17 | $sth = $self->{dbh}->prepare($q); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 17 | $sth->execute(@p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 17 | ▶ | while (my $row = $sth->fetchrow_arrayref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 14 | push(@result, File::FStore::File->_new(store => $self, dbid => $row->[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 17 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 17 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 3 | return @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 14 | ▶ | croak 'Multiple results for query but called in scalar context' if scalar(@result) > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 14 | ▶ | croak 'No results for query but called in scalar context' if scalar(@result) < 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 14 | return $result[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | die 'BUG'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | ▶ | sub scrub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scrub: called CC=3 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | ▶ | $self->in_transaction(ro => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | ▶ | opendir(my $algodir, $self->_directory('v2' => 'by')) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | ▶ | while (defined(my $algoent = readdir($algodir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 12 | ▶ | next if $algoent =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 10 | $self->_scrub_dir($algoent => $self->_directory(v2 => by => $algoent)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | closedir($algodir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | ▶ | if (opendir(my $algodir, $self->_directory('v2' => 'ni'))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | $self->in_transaction(ro => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | while (defined(my $algoent = readdir($algodir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my $dirname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | next if $algoent =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $dirname = $self->_directory(v2 => ni => $algoent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | opendir(my $dir, $dirname) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | while (defined(my $fn = readdir($dir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $fullname = File::Spec->catfile($dirname, $fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | next if $fn =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | unlink($fullname) unless -e $fullname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | closedir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | closedir($algodir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | ▶ | sub scan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | my %extra; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | foreach my $key (qw(update no_digests on_pre_set on_post_set)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 8 | $extra{$key} = delete $opts{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 2 | ▶ | $extra{update} //= 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$extra{"update"} //= "all"
MC/DC100%1/1
$extra{"update"} //= "all"
$extra{"update"}
Truth table100%2/2
A
A= $extra{"update"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | ▶ | $self->in_transaction(rw => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | my $insert = $self->{dbh}->prepare('INSERT OR IGNORE INTO file (filename) VALUES (?)'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 2 | ▶ | opendir(my $dir, $self->_directory('v2', 'store')) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | ▶ | while (defined(my $ent = readdir($dir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 8 | my $dirname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 8 | ▶ | next if $ent =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 4 | $dirname = $self->_directory('v2', 'store', $ent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 4 | ▶ | if (-d $dirname) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 2 | $self->_scan_subdir($dirname, dbprefix => $ent, insert => $insert, %extra); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 2 | closedir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | ▶ | sub fix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fix: called CC=8 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | my ($self, @fixes) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | my %fixes = map {$_ => 1} @fixes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | foreach my $fix (qw(upgrade scrub remove-inode remove-mediasubtype remove-inodeise scan)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 6 | ▶ | next unless delete $fixes{$fix}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | ▶ | if ($fix eq 'scrub') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | $self->scrub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } elsif ($fix eq 'scan') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | $self->scan; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } elsif ($fix eq 'upgrade') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | $self->migration->upgrade; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } elsif ($fix =~ /^remove-(inode|mediasubtype|inodeise)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $what = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $sth = $self->{dbh}->prepare('DELETE FROM file_properties WHERE key = ?'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $sth->execute($what);; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | croak 'BUG'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 1 | ▶ | if (scalar keys %fixes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | croak 'Invalid/unknown fixes passed: '.join(', ', keys %fixes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | #@returns File::FStore::Adder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 1 | ▶ | sub new_adder { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_adder: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 1 | require File::FStore::Adder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | return File::FStore::Adder->_new(store => $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | #@returns File::FStore::Migration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 1 | ▶ | sub migration { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
migration: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 1 | require File::FStore::Migration; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | return File::FStore::Migration->_new(store => $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | #@deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | sub export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return $self->migration->export_data(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | #@deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | sub import_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import_data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return $self->migration->import_data(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | sub add_digest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_digest: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my ($self, $digests, @opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $path = $self->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my %used_digests = map {$_ => undef} @{$self->{used_digests}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | croak 'Stray options passed' if scalar @opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | $digests = [split(/\s*,\s*|\s+/, $digests)] unless ref $digests; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | foreach my $d (@{$digests}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | next if exists $used_digests{$d}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | croak 'Invalid digest: '.$d unless defined $_valid_digests{$d}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | mkdir(File::Spec->catdir($path, qw(v2 by), $d)) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $used_digests{$d} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | @{$self->{used_digests}} = keys %used_digests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | #@deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | sub attach { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attach: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $self->so_attach(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | #@deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub db { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
db: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return $self->so_get('db', %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | #@deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub extractor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractor: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | return $self->so_get('extractor', %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | #@returns File::Information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 4 | ▶ | sub fii { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fii: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 4 | my $fii = $self->so_get('fii', default => undef, no_defaults => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 4 | ▶ | return $fii if defined $fii; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | require File::Information; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | File::Information->VERSION(v0.06); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | $fii = File::Information->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | db => $self->so_get('db', default => undef, no_defaults => 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | extractor => $self->so_get('extractor', default => undef, no_defaults => 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 2 | $self->so_attach(fii => $fii); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 2 | return $fii; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # --- Overrides for Data::Identifier::Interface::Known --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 5 | ▶ | sub _known_provider { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_known_provider: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 5 | my ($pkg, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 5 | return $pkg->File::FStore::File::_known_provider(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 17 | ▶ | sub _placeholders { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_placeholders: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 17 | my ($self, $field, $list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 17 | my $placeholders = '?,' x scalar(@{$list}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 17 | $placeholders =~ s/,$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 17 | return sprintf('%s IN (%s)', $field, $placeholders); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 8 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 8 | ▶ | $self->{dbh}->disconnect if defined $self->{dbh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 8 | %{$self} = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 38 | ▶ | sub _file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 38 | my ($self, @comp) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 38 | return File::Spec->catfile($self->{path}, @comp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 28 | ▶ | sub _directory { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_directory: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 28 | my ($self, @comp) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 28 | return File::Spec->catdir($self->{path}, @comp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 4 | ▶ | sub _used_digests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_used_digests: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 4 | return $self->{used_digests}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 3 | ▶ | sub _used_digests_ni { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_used_digests_ni: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 3 | return $self->{used_digests_ni}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 3 | ▶ | sub _init_link_style { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_link_style: called CC=5 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 3 | ▶ | unless ($self->{_init_link_style}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | my $link_style = $self->setting('link_style'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 2 | $self->{_init_link_style} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 2 | ▶ | if ($link_style eq '2-level') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | foreach my $digest (@{$self->_used_digests}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | for (my $i = 0; $i < 0x100; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | mkdir($self->_directory(v2 => by => $digest => sprintf('%02x', $i))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | ▶ | sub _init_store_style { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_store_style: called CC=6 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | ▶ | unless ($self->{_init_store_style}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | my $store_style = $self->setting('store_style'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | $self->{_init_store_style} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1 | ▶ | if ($store_style eq '2-level-contentise' || $store_style eq '1-level-contentise') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$store_style eq "2-level-contentise" or $store_style eq "1-level-contentise"
MC/DC0%0/2
$store_style eq "2-level-contentise" or $store_style eq "1-level-contentise"
$store_style eq "2-level-contentise"
$store_style eq "1-level-contentise"
Truth table33%1/3
A or B
A= $store_style eq "2-level-contentise"B= $store_style eq "1-level-contentise"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | mkdir($self->_directory(v2 => store => 'by-contentise')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | ▶ | if ($store_style eq '2-level-contentise') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | for (my $i = 0; $i < 0x100; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | mkdir($self->_directory(v2 => store => 'by-contentise' => sprintf('%02x', $i))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | ▶ | sub _scan_subdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scan_subdir: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | my ($self, $dirname, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 2 | my $dbprefix = $opts{dbprefix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 2 | ▶ | opendir(my $dir, $dirname) // croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
opendir(my $dir, $dirname) // croak($!)
MC/DC0%0/1
opendir(my $dir, $dirname) // croak($!)
opendir(my $dir, $dirname)
Truth table50%1/2
A
A= opendir(my $dir, $dirname)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 2 | ▶ | while (defined(my $ent = readdir($dir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 6 | my $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | my $fh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 6 | ▶ | next if $ent =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | $filename = File::Spec->catfile($dirname, $ent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 2 | open($fh, '<', $filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 2 | ▶ | if ($fh && -f $fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fh and -f $fh
MC/DC0%0/2
$fh and -f $fh
$fh
-f $fh
Truth table33%1/3
A and B
A= $fhB= -f $fh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 2 | my $dbname = File::Spec->catfile($dbprefix, $ent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 2 | $self->_scan_file($fh, $dbname, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | #warn sprintf('ent=<%s>, filename=<%s>, dbprefix=<%s>, dbname=<%s>', $ent, $filename, $dbprefix, $dbname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $self->_scan_subdir(File::Spec->catdir($dirname, $ent), %opts, dbprefix => File::Spec->catdir($dbprefix, $ent)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 2 | closedir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 2 | ▶ | sub _scan_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scan_file: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 2 | my ($self, $fh, $dbname, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 2 | my File::FStore::File $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 2 | my $update = $opts{update}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 2 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 2 | $opts{insert}->execute($dbname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 2 | $new = $opts{insert}->rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 2 | $file = $self->query(dbname => $dbname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 2 | $file->_open(fh => $fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 2 | ▶ | if ($update eq 'all' || ($new && $update eq 'new')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$update eq "all" or $new and $update eq "new"
$new and $update eq "new"
MC/DC33%1/3
$update eq "all" or $new and $update eq "new"
$update eq "all"
$new
$update eq "new"
Truth table50%2/4
A or B and C
A= $update eq "all"B= $newC= $update eq "new"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 1 | $file->update(%opts{qw(no_digests on_pre_set on_post_set)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 1 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | $atime,$mtime,$ctime,$blksize,$blocks) = $file->stat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 1 | ▶ | $opts{on_pre_set}->($file) if defined $opts{on_pre_set}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 1 | $file->set({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | properties => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | size => $size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | inode => $ino, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 1 | ▶ | $opts{on_post_set}->($file) if defined $opts{on_post_set}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 10 | ▶ | sub _scrub_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scrub_dir: called CC=12 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 10 | my ($self, $algoent, $dirname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 10 | ▶ | opendir(my $dir, $dirname) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 10 | ▶ | while (defined(my $ent = readdir($dir))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 30 | my $fullname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | my $hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 30 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | $atime,$mtime,$ctime,$blksize,$blocks); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 30 | my $bad = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 30 | ▶ | next if $ent =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 10 | $fullname = File::Spec->catdir($dirname, $ent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 10 | ▶ | if (-d $fullname) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $self->_scrub_dir($algoent => $fullname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 10 | $fullname = File::Spec->catfile($dirname, $ent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 10 | ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | $atime,$mtime,$ctime,$blksize,$blocks) = stat($fullname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 10 | ▶ | if (defined $size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 10 | my ($hash) = $ent =~ /^([0-9a-fA-F]+)(?:\..+)?$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 10 | ▶ | if (defined $hash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 10 | my $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 10 | $hash = lc($hash); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 10 | $file = eval {$self->query(digests => $algoent => $hash)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 10 | ▶ | if (defined $file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 10 | ▶ | my $want_size = eval { $file->get(properties => 'size') } // $size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$file->get("properties", "size")
}
} // $size
MC/DC0%0/2
eval {
do {
$file->get("properties", "size")
}
} // $size
eval {
do {
$file->get("properties", "size")
}
}
$size
Truth table33%1/3
A // B
A= eval {
do {
$file->get("properties", "size")
}
}B= $size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 10 | ▶ | if ($size == $want_size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 10 | $bad = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | #warn $algoent.' -> '.$ent.' -> '.$bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 10 | ▶ | if ($bad) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | unlink($fullname) or croak $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 10 | closedir($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||