| 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::Adder; | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Data::Identifier; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use File::FStore::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use parent 'File::FStore::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | our $VERSION = v0.08; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub link_in { | ||||||||||||||||||||||||||
|
Subroutine
link_in: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 0 | my ($self, $if) = @_; | |||||||||||||||||||||||||||
| 27 | 0 | my $tmpname = $self->_temp_filename; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | link($if, $tmpname) or croak $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | sub move_in { | ||||||||||||||||||||||||||
|
Subroutine
move_in: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 1 | my ($self, $if) = @_; | |||||||||||||||||||||||||||
| 35 | 1 | my $tmpname = $self->_temp_filename; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | rename($if, $tmpname) or croak $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | ▶ | sub set { | ||||||||||||||||||||||||||
|
Subroutine
set: called CC=9 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 1 | my ($self, $domain, $key, $value) = @_; | |||||||||||||||||||||||||||
| 43 | 1 | my $data; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # get things in standard format: | ||||||||||||||||||||||||||||
| 46 | 1 | ▶ | if (defined($key)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 0 | $data = {$domain => {$key => $value}}; | |||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||
| 50 | 0 | $data = {$domain => $key}; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||||||||||
| 53 | 1 | $data = $domain; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # now try to merge: | ||||||||||||||||||||||||||||
| 57 | 1 | foreach my $cdomain (keys %{$data}) { | |||||||||||||||||||||||||||
| 58 | 2 | my $ddata = $data->{$cdomain}; | |||||||||||||||||||||||||||
| 59 | 2 | ▶ | my $dd = $self->{data}{$cdomain} // croak 'Invalid domain: '.$cdomain; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"data"}{$cdomain} // croak('Invalid domain: ' . $cdomain)
MC/DC0%0/1
$self->{"data"}{$cdomain} // croak('Invalid domain: ' . $cdomain)
$self->{"data"}{$cdomain}
Truth table50%1/2
A
A= $self->{"data"}{$cdomain}
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | foreach my $key (keys %{$ddata}) { | |||||||||||||||||||||||||||
| 62 | 12 | ▶ | my $v = $ddata->{$key} // next; | ||||||||||||||||||||||||||
|
Condition50%1/2
$ddata->{$key} // (next)
MC/DC0%0/1
$ddata->{$key} // (next)
$ddata->{$key}
Truth table50%1/2
A
A= $ddata->{$key}
| |||||||||||||||||||||||||||||
| 63 | 12 | ▶ | $dd->{$key} //= $v; | ||||||||||||||||||||||||||
|
Condition33%1/3
$dd->{$key} //= $v
MC/DC0%0/2
$dd->{$key} //= $v
$dd->{$key}
$v
Truth table33%1/3
A //= B
A= $dd->{$key}B= $v
| |||||||||||||||||||||||||||||
| 64 | 12 | ▶ | croak 'Data mismatch domain '.$cdomain.' key '.$key if $dd->{$key} ne $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | ▶ | sub done { | ||||||||||||||||||||||||||
|
Subroutine
done: called CC=18 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 72 | 1 | my $link = $self->fii->for_link($self->_temp_filename); | |||||||||||||||||||||||||||
| 73 | 1 | my $inode = $link->inode; | |||||||||||||||||||||||||||
| 74 | my %data = ( | ||||||||||||||||||||||||||||
| 75 | 1 | properties => {%{$self->{data}{properties}}}, | |||||||||||||||||||||||||||
| 76 | 1 | digests => {%{$self->{data}{digests}}}, | |||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | ▶ | return if defined $self->{done}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 1 | $self->{done} = 1; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | foreach my $lifecycle (qw(final current)) { | |||||||||||||||||||||||||||
| 83 | 2 | ▶ | if (defined(my $v = $link->get('size', default => undef))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 2 | ▶ | $data{properties}{size} //= $v; | ||||||||||||||||||||||||||
|
Condition66%2/3
$data{"properties"}{"size"} //= $v
MC/DC0%0/2
$data{"properties"}{"size"} //= $v
$data{"properties"}{"size"}
$v
Truth table66%2/3
A //= B
A= $data{"properties"}{"size"}B= $v
| |||||||||||||||||||||||||||||
| 85 | 2 | ▶ | croak 'Invalid size' if $data{properties}{size} != $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | ▶ | if (defined(my $v = $link->get('mediatype', default => undef))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $data{properties}{mediasubtype} //= $v; | ||||||||||||||||||||||||||
|
Condition0%0/3
$data{"properties"}{"mediasubtype"} //= $v
MC/DC0%0/2
$data{"properties"}{"mediasubtype"} //= $v
$data{"properties"}{"mediasubtype"}
$v
Truth table0%0/3
A //= B
A= $data{"properties"}{"mediasubtype"}B= $v
| |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | croak 'Invalid mediasubtype' if $data{properties}{mediasubtype} ne $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 2 | ▶ | if (defined(my $v = $link->get('contentise', default => undef))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 2 | ▶ | $data{properties}{contentise} //= $v; | ||||||||||||||||||||||||||
|
Condition66%2/3
$data{"properties"}{"contentise"} //= $v
MC/DC0%0/2
$data{"properties"}{"contentise"} //= $v
$data{"properties"}{"contentise"}
$v
Truth table66%2/3
A //= B
A= $data{"properties"}{"contentise"}B= $v
| |||||||||||||||||||||||||||||
| 95 | 2 | ▶ | croak 'Invalid contentise' if $data{properties}{contentise} ne $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 2 | foreach my $digest (@{$self->_used_digests}) { | |||||||||||||||||||||||||||
| 99 | 20 | ▶ | if (defined(my $v = $inode->digest($digest, lifecycle => $lifecycle, default => undef))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 10 | ▶ | $data{digests}{$digest} //= $v; | ||||||||||||||||||||||||||
|
Condition33%1/3
$data{"digests"}{$digest} //= $v
MC/DC0%0/2
$data{"digests"}{$digest} //= $v
$data{"digests"}{$digest}
$v
Truth table33%1/3
A //= B
A= $data{"digests"}{$digest}B= $v
| |||||||||||||||||||||||||||||
| 101 | 10 | ▶ | croak 'Digest mismatch for '.$digest if $data{digests}{$digest} ne $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 1 | $self->set(\%data); | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | ▶ | if (defined $data{properties}{contentise}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 1 | my $contentise = $self->{contentise} = Data::Identifier->new(ise => $data{properties}{contentise}); | |||||||||||||||||||||||||||
| 110 | 1 | my @res = $self->store->query(properties => contentise => $contentise->uuid); | |||||||||||||||||||||||||||
| 111 | 1 | ▶ | if (scalar @res) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | croak 'File already in store'; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 3 | ▶ | sub reset { | ||||||||||||||||||||||||||
|
Subroutine
reset: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 119 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 3 | ▶ | if (defined(my $fn = delete($self->{temp_filename}))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 1 | unlink($fn); | |||||||||||||||||||||||||||
| 123 | }; | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 3 | %{$self} = ( | |||||||||||||||||||||||||||
| 126 | store => $self->store, | ||||||||||||||||||||||||||||
| 127 | data => { | ||||||||||||||||||||||||||||
| 128 | properties => {}, | ||||||||||||||||||||||||||||
| 129 | digests => {}, | ||||||||||||||||||||||||||||
| 130 | }, | ||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | #@returns File::FStore::File | ||||||||||||||||||||||||||||
| 136 | 1 | ▶ | sub insert { | ||||||||||||||||||||||||||
|
Subroutine
insert: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 138 | 1 | my $tmpname = $self->_temp_filename; | |||||||||||||||||||||||||||
| 139 | 1 | my $store = $self->store; | |||||||||||||||||||||||||||
| 140 | 1 | my $dbname; | |||||||||||||||||||||||||||
| 141 | my $fullname; | ||||||||||||||||||||||||||||
| 142 | 1 | my File::FStore::File $file; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 1 | $self->done; | |||||||||||||||||||||||||||
| 145 | 1 | $dbname = $self->_target_filename; | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||
| 148 | 1 | my @res = ( | |||||||||||||||||||||||||||
| 149 | $store->query(properties => contentise => $self->contentise), | ||||||||||||||||||||||||||||
| 150 | $store->query(dbname => $dbname), | ||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||
| 152 | 1 | ▶ | if (scalar @res) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 0 | croak 'File already in store'; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | $fullname = $store->_file(v2 => store => $dbname); | |||||||||||||||||||||||||||
| 158 | 1 | ▶ | if (-e $fullname) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | croak 'File with duplicates dbname already in store'; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 1 | mkdir($store->_directory(v2 => store => $self->_target_dirname)); # ignore errors. | |||||||||||||||||||||||||||
| 163 | 1 | ▶ | rename($tmpname => $fullname) or croak $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 1 | $store->scan(update => 'none', no_digests => 1); | |||||||||||||||||||||||||||
| 166 | 1 | $file = $store->query(dbname => $dbname); | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 1 | $file->set($self->{data}); | |||||||||||||||||||||||||||
| 169 | 1 | $file->update(no_digests => 1); | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 1 | $self->reset; | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 1 | return $file; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||
| 177 | 1 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 178 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 179 | 1 | $self->reset; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 1 | ▶ | sub _new { | ||||||||||||||||||||||||||
|
Subroutine
_new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 183 | 1 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||
| 184 | 1 | my $self = $pkg->SUPER::_new(%opts); | |||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 1 | $self->store->_init_store_style; | |||||||||||||||||||||||||||
| 187 | 1 | $self->reset; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 1 | return $self; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 3 | ▶ | sub _temp_filename { | ||||||||||||||||||||||||||
|
Subroutine
_temp_filename: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 193 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 194 | 3 | ▶ | return $self->{temp_filename} //= do { | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"temp_filename"} //= do {
state $c = int rand 65535;
my $base = sprintf("tmp.%u.%u.%u.%u.%u.%u.%u", $$, $^T, time, int rand 65535, int $self->store, int $self, $c++);
my $filename = $self->store->_file("v2", "store", $base);
croak('Tempfile already exists: ' . $filename) if -e $filename;
$filename
}
MC/DC0%0/2
$self->{"temp_filename"} //= do {
state $c = int rand 65535;
my $base = sprintf("tmp.%u.%u.%u.%u.%u.%u.%u", $$, $^T, time, int rand 65535, int $self->store, int $self, $c++);
my $filename = $self->store->_file("v2", "store", $base);
croak('Tempfile already exists: ' . $filename) if -e $filename;
$filename
}
$self->{"temp_filename"}
do {
state $c = int rand 65535;
my $base = sprintf("tmp.%u.%u.%u.%u.%u.%u.%u", $$, $^T, time, int rand 65535, int $self->store, int $self, $c++);
my $filename = $self->store->_file("v2", "store", $base);
croak('Tempfile already exists: ' . $filename) if -e $filename;
$filename
}
Truth table66%2/3
A //= B
A= $self->{"temp_filename"}B= do {
state $c = int rand 65535;
my $base = sprintf("tmp.%u.%u.%u.%u.%u.%u.%u", $$, $^T, time, int rand 65535, int $self->store, int $self, $c++);
my $filename = $self->store->_file("v2", "store", $base);
croak('Tempfile already exists: ' . $filename) if -e $filename;
$filename
}
| |||||||||||||||||||||||||||||
| 195 | 1 | state $c = int(rand 65535); | |||||||||||||||||||||||||||
| 196 | 1 | my $base = sprintf('tmp.%u.%u.%u.%u.%u.%u.%u', | |||||||||||||||||||||||||||
| 197 | $$, $^T, time, | ||||||||||||||||||||||||||||
| 198 | int(rand 65535), int($self->store), int($self), | ||||||||||||||||||||||||||||
| 199 | $c++, | ||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||
| 201 | 1 | my $filename = $self->store->_file(v2 => store => $base); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 1 | ▶ | croak 'Tempfile already exists: '.$filename if -e $filename; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 1 | $filename; | |||||||||||||||||||||||||||
| 206 | }; | ||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 2 | ▶ | sub _target_dirname { | ||||||||||||||||||||||||||
|
Subroutine
_target_dirname: called CC=4 SCAR=19.4
| |||||||||||||||||||||||||||||
| 210 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 211 | 2 | ▶ | my $store_style = $self->store->setting('store_style') // File::FStore->DEFAULT_STORE_STYLE; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->store->setting("store_style") // "File::FStore"->DEFAULT_STORE_STYLE
MC/DC0%0/2
$self->store->setting("store_style") // "File::FStore"->DEFAULT_STORE_STYLE
$self->store->setting("store_style")
"File::FStore"->DEFAULT_STORE_STYLE
Truth table33%1/3
A // B
A= $self->store->setting("store_style")B= "File::FStore"->DEFAULT_STORE_STYLE
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 2 | ▶ | if ($store_style eq '1-level-contentise') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 214 | 2 | return 'by-contentise'; | |||||||||||||||||||||||||||
| 215 | } elsif ($store_style eq '2-level-contentise') { | ||||||||||||||||||||||||||||
| 216 | 0 | my $contentise = $self->contentise; | |||||||||||||||||||||||||||
| 217 | 0 | return File::Spec->catdir('by-contentise', substr($contentise, 0, 2)); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | croak 'BUG: Invalid store style'; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 1 | ▶ | sub _target_filename { | ||||||||||||||||||||||||||
|
Subroutine
_target_filename: called CC=5 SCAR=20.3
| |||||||||||||||||||||||||||||
| 224 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 225 | 1 | ▶ | my $store_style = $self->store->setting('store_style') // File::FStore->DEFAULT_STORE_STYLE; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->store->setting("store_style") // "File::FStore"->DEFAULT_STORE_STYLE
MC/DC0%0/2
$self->store->setting("store_style") // "File::FStore"->DEFAULT_STORE_STYLE
$self->store->setting("store_style")
"File::FStore"->DEFAULT_STORE_STYLE
Truth table33%1/3
A // B
A= $self->store->setting("store_style")B= "File::FStore"->DEFAULT_STORE_STYLE
| |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 1 | ▶ | if ($store_style eq '1-level-contentise' || $store_style eq '2-level-contentise') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$store_style eq "1-level-contentise" or $store_style eq "2-level-contentise"
MC/DC0%0/2
$store_style eq "1-level-contentise" or $store_style eq "2-level-contentise"
$store_style eq "1-level-contentise"
$store_style eq "2-level-contentise"
Truth table33%1/3
A or B
A= $store_style eq "1-level-contentise"B= $store_style eq "2-level-contentise"
| |||||||||||||||||||||||||||||
| 228 | 1 | my $contentise = $self->contentise; | |||||||||||||||||||||||||||
| 229 | 1 | ▶ | return $self->{target_filename} //= File::Spec->catfile($self->_target_dirname, $contentise); | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"target_filename"} //= "File::Spec"->catfile($self->_target_dirname, $contentise)
MC/DC0%0/2
$self->{"target_filename"} //= "File::Spec"->catfile($self->_target_dirname, $contentise)
$self->{"target_filename"}
"File::Spec"->catfile($self->_target_dirname, $contentise)
Truth table33%1/3
A //= B
A= $self->{"target_filename"}B= "File::Spec"->catfile($self->_target_dirname, $contentise)
| |||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | croak 'BUG: Invalid store style'; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 2 | ▶ | sub _used_digests { | ||||||||||||||||||||||||||
|
Subroutine
_used_digests: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 236 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 237 | 2 | ▶ | return $self->{used_digests} //= $self->store->_used_digests; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"used_digests"} //= $self->store->_used_digests
MC/DC0%0/2
$self->{"used_digests"} //= $self->store->_used_digests
$self->{"used_digests"}
$self->store->_used_digests
Truth table66%2/3
A //= B
A= $self->{"used_digests"}B= $self->store->_used_digests
| |||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 2 | 1; | |||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | __END__ | ||||||||||||||||||||||||||||