| 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::File; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use Fcntl qw(SEEK_SET S_IWUSR S_IWGRP S_IWOTH); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Data::Identifier; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use Data::Identifier::Generate; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use File::FStore; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use parent qw(File::FStore::Base Data::Identifier::Interface::Known); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | WRITE_BITS => S_IWUSR|S_IWGRP|S_IWOTH, | |||||||||||||||||||||||||||||||||||||||||
| 27 | RE_ISE => qr<^(?:[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}|[1-3](?:\.(?:0|[1-9][0-9]*))+|[a-zA-Z][a-zA-Z0-9\+\.\-]+:.*)$>, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | MEDIA_SUBTYPE_GENERATOR => Data::Identifier->new(uuid => 'a649d48d-35b0-4454-81af-c5fd2eb40373')->register, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | MEDIA_SUBTYPE_NAMESPACE => Data::Identifier->new(uuid => '50d7c533-2d9b-4208-b560-bcbbf75ce3f9')->register, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | our $VERSION = v0.07; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | my @_xattr_hashes = qw(sha-1-160 sha-2-256 sha-3-512); | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | my %_valid_properties = ( | |||||||||||||||||||||||||||||||||||||||||
| 38 | size => qr<^(?:0|[1-9][0-9]*)$>, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | inode => qr<>, # any | ||||||||||||||||||||||||||||||||||||||||||
| 40 | mediasubtype => qr<^(?:application|audio|example|font|haptics|image|message|model|multipart|text|video)/[0-9a-zA-Z][0-9a-zA-Z\!\#\$\&\-\^_\.\+]{0,126}$>, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | contentise => RE_ISE, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | inodeise => RE_ISE, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | my %_exts = ( | |||||||||||||||||||||||||||||||||||||||||
| 46 | 'image/jpeg' => 'jpg', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'image/png' => 'png', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'image/gif' => 'gif', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'image/vnd.microsoft.icon' => 'ico', | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'audio/flac' => 'flac', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'application/pdf' => 'pdf', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'application/zip' => 'zip', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'text/plain' => 'txt', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | my @_media_subtypes = map { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | Data::Identifier::Generate->generic( | |||||||||||||||||||||||||||||||||||||||||
| 58 | generator => MEDIA_SUBTYPE_GENERATOR, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | namespace => MEDIA_SUBTYPE_NAMESPACE, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | style => 'name-based', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | request => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | )->register | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } keys %_exts; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | my %_db_tags = ( | |||||||||||||||||||||||||||||||||||||||||
| 66 | # well known tags: | ||||||||||||||||||||||||||||||||||||||||||
| 67 | final_file_size => Data::Identifier->new(uuid => '1cd4a6c6-0d7c-48d1-81e7-4e8d41fdb45d'), | ||||||||||||||||||||||||||||||||||||||||||
| 68 | final_file_encoding => Data::Identifier->new(uuid => '448c50a8-c847-4bc7-856e-0db5fea8f23b'), | ||||||||||||||||||||||||||||||||||||||||||
| 69 | final_file_hash => Data::Identifier->new(uuid => '79385945-0963-44aa-880a-bca4a42e9002'), | ||||||||||||||||||||||||||||||||||||||||||
| 70 | also_has_role => Data::Identifier->new(uuid => 'd2750351-aed7-4ade-aa80-c32436cc6030'), | ||||||||||||||||||||||||||||||||||||||||||
| 71 | also_has_state => Data::Identifier->new(uuid => '4c426c3c-900e-4350-8443-e2149869fbc9'), | ||||||||||||||||||||||||||||||||||||||||||
| 72 | has_final_state => Data::Identifier->new(uuid => '54d30193-2000-4d8a-8c28-3fa5af4cad6b'), | ||||||||||||||||||||||||||||||||||||||||||
| 73 | specific_proto_file_state => Data::Identifier->new(uuid => '63da70a8-78a4-51b0-8b87-86872b474a5d'), | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 6 | ▶ | sub dbname { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbname: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | ▶ | return $self->{dbname} //= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"dbname"} //= do {
my $sth = $self->_prepare("SELECT filename FROM file WHERE id = ?");
my $res;
$sth->execute($self->{"dbid"});
$res = $sth->fetchall_arrayref;
$res->[0][0] // croak("Database error")
}
MC/DC0%0/2
$self->{"dbname"} //= do {
my $sth = $self->_prepare("SELECT filename FROM file WHERE id = ?");
my $res;
$sth->execute($self->{"dbid"});
$res = $sth->fetchall_arrayref;
$res->[0][0] // croak("Database error")
}
$self->{"dbname"}
do {
my $sth = $self->_prepare("SELECT filename FROM file WHERE id = ?");
my $res;
$sth->execute($self->{"dbid"});
$res = $sth->fetchall_arrayref;
$res->[0][0] // croak("Database error")
}
Truth table66%2/3
A //= B
A= $self->{"dbname"}B= do {
my $sth = $self->_prepare("SELECT filename FROM file WHERE id = ?");
my $res;
$sth->execute($self->{"dbid"});
$res = $sth->fetchall_arrayref;
$res->[0][0] // croak("Database error")
}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | my $sth = $self->_prepare('SELECT filename FROM file WHERE id = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | my $res; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | $sth->execute($self->{dbid}); | |||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | $res = $sth->fetchall_arrayref; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | $res->[0][0] // croak 'Database error'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$res->[0][0] // croak("Database error")
MC/DC0%0/1
$res->[0][0] // croak("Database error")
$res->[0][0]
Truth table50%1/2
A
A= $res->[0][0]
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | ▶ | sub filename { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | ▶ | return $self->{filename} //= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"filename"} //= do {
$self->store->_file(("v2", "store"), $self->dbname)
}
MC/DC0%0/2
$self->{"filename"} //= do {
$self->store->_file(("v2", "store"), $self->dbname)
}
$self->{"filename"}
do {
$self->store->_file(("v2", "store"), $self->dbname)
}
Truth table66%2/3
A //= B
A= $self->{"filename"}B= do {
$self->store->_file(("v2", "store"), $self->dbname)
}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | $self->store->_file(qw(v2 store), $self->dbname); | |||||||||||||||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | ▶ | sub open { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | my $fh = $self->_open; | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | $self->stat; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | $self->_detach_fh; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | return $fh; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub link_out { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
link_out: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my ($self, $filename) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | link($self->filename, $filename) or croak $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub symlink_out { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symlink_out: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my ($self, $filename) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | symlink($self->filename, $filename) or croak $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: called CC=2 SCAR=9.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | my File::FStore $store = $self->store; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | my $no_digests = delete($opts{no_digests}); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | my $on_pre_set = delete($opts{on_pre_set}); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | my $on_post_set = delete($opts{on_post_set}); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | my $inode; | |||||||||||||||||||||||||||||||||||||||||
| 129 | my $properties; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | my $digests; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | ▶ | croak 'Stray options passed' if scalar keys %opts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | $store->_init_link_style; | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | $store->in_transaction(rw => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=67 SCAR=67.3
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | my $fh = $self->_open; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | delete $self->{stat}; #clear stat cache. | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | $inode = $self->as('File::Information::Inode'); | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # Perform a verify via File::Information | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | unless ($no_digests) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | my $verify_result = $inode->verify; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | unless ($verify_result->has_passed || $verify_result->has_no_data || $verify_result->has_insufficient_data) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$verify_result->has_passed or $verify_result->has_no_data or $verify_result->has_insufficient_data
$verify_result->has_passed or $verify_result->has_no_data
MC/DC0%0/3
$verify_result->has_passed or $verify_result->has_no_data or $verify_result->has_insufficient_data
$verify_result->has_passed
$verify_result->has_no_data
$verify_result->has_insufficient_data
Truth table25%1/4
A or B or C
A= $verify_result->has_passedB= $verify_result->has_no_dataC= $verify_result->has_insufficient_data
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | croak sprintf('File (%s) is in bad state: %s', $self->dbname, $verify_result->status); | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # Perform a verify with our own data. | ||||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, | |||||||||||||||||||||||||||||||||||||||||
| 155 | $atime,$mtime,$ctime,$blksize,$blocks) = $self->stat; | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | ▶ | $properties = $data->{properties} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"properties"} //= {}
MC/DC0%0/1
$data->{"properties"} //= {}
$data->{"properties"}
Truth table50%1/2
A
A= $data->{"properties"}
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | $digests = $data->{digests} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"digests"} //= {}
MC/DC0%0/1
$data->{"digests"} //= {}
$data->{"digests"}
Truth table50%1/2
A
A= $data->{"digests"}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | ▶ | $properties->{size} //= $size; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$properties->{"size"} //= $size
MC/DC0%0/2
$properties->{"size"} //= $size
$properties->{"size"}
$size
Truth table33%1/3
A //= B
A= $properties->{"size"}B= $size
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | croak 'Size mismatch' if $properties->{size} != $size; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | ▶ | $properties->{inode} //= $ino; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$properties->{"inode"} //= $ino
MC/DC0%0/2
$properties->{"inode"} //= $ino
$properties->{"inode"}
$ino
Truth table33%1/3
A //= B
A= $properties->{"inode"}B= $ino
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | croak 'inode mismatch' if $properties->{inode} != $ino; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | # Load some basic properties, first the final values, than the current ones. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | foreach my $lifecycle (qw(final current)) { | |||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | ▶ | if (defined(my $v = $inode->get('size', lifecycle => $lifecycle, default => undef))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | $properties->{size} //= $v; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$properties->{"size"} //= $v
MC/DC0%0/2
$properties->{"size"} //= $v
$properties->{"size"}
$v
Truth table33%1/3
A //= B
A= $properties->{"size"}B= $v
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | croak 'Size mismatch' if $properties->{size} != $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | ▶ | if (defined(my $v = $inode->get('mediatype', lifecycle => $lifecycle, default => undef, as => 'mediatype'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $properties->{mediasubtype} //= $v; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$properties->{"mediasubtype"} //= $v
MC/DC0%0/2
$properties->{"mediasubtype"} //= $v
$properties->{"mediasubtype"}
$v
Truth table0%0/3
A //= B
A= $properties->{"mediasubtype"}B= $v
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | croak sprintf('Media subtype mismatch on (%s): "%s" vs. "%s"', $self->dbname, $properties->{mediasubtype}, $v) if $properties->{mediasubtype} ne $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | ▶ | if (defined(my $v = $inode->get('inodeise', lifecycle => $lifecycle, default => undef, as => 'ise'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $properties->{inodeise} //= $v; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$properties->{"inodeise"} //= $v
MC/DC0%0/2
$properties->{"inodeise"} //= $v
$properties->{"inodeise"}
$v
Truth table0%0/3
A //= B
A= $properties->{"inodeise"}B= $v
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | # XXX: We ignore mismatches here. This can be for a number of reasons. Such as switches between different sources of the value. | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # TODO: A better policy should be implemented later on. | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | ▶ | if (defined(my $v = $inode->get('st_ino', lifecycle => $lifecycle, default => undef))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | $properties->{inode} //= $v; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$properties->{"inode"} //= $v
MC/DC0%0/2
$properties->{"inode"} //= $v
$properties->{"inode"}
$v
Truth table33%1/3
A //= B
A= $properties->{"inode"}B= $v
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | croak 'inode mismatch' if $properties->{inode} != $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | # First load all known final ones. | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | foreach my $digest (@{$self->_used_digests}, @{$self->_used_digests_ni}) { | |||||||||||||||||||||||||||||||||||||||||
| 191 | 20 | ▶ | if (defined(my $v = $inode->digest($digest, lifecycle => 'final', default => undef))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $digests->{$digest} //= $v; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$digests->{$digest} //= $v
MC/DC0%0/2
$digests->{$digest} //= $v
$digests->{$digest}
$v
Truth table0%0/3
A //= B
A= $digests->{$digest}B= $v
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | croak 'Digest mismatch for '.$digest if $digests->{$digest} ne $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # Then test against the current ones. | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | unless ($no_digests) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | foreach my $digest (@{$self->_used_digests}, @{$self->_used_digests_ni}) { | |||||||||||||||||||||||||||||||||||||||||
| 200 | 10 | ▶ | if (defined(my $v = $inode->digest($digest, default => undef))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 10 | ▶ | $digests->{$digest} //= $v; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$digests->{$digest} //= $v
MC/DC0%0/2
$digests->{$digest} //= $v
$digests->{$digest}
$v
Truth table33%1/3
A //= B
A= $digests->{$digest}B= $v
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 10 | ▶ | croak 'Digest mismatch for '.$digest if $digests->{$digest} ne $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | if (defined(my $contentise = eval {$self->_calculate_contentise($data)->uuid})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | ▶ | $properties->{contentise} //= $contentise; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$properties->{"contentise"} //= $contentise
MC/DC0%0/2
$properties->{"contentise"} //= $contentise
$properties->{"contentise"}
$contentise
Truth table33%1/3
A //= B
A= $properties->{"contentise"}B= $contentise
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | croak 'Content ISE mismatch' if $properties->{contentise} ne $contentise; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | $on_pre_set->($self) if defined $on_pre_set; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | $self->set($data); | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | # Create symlinks: | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | if ((my $link_style = $store->setting('link_style')) ne 'none') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | state $up = File::Spec->updir; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | my $dbname = $self->dbname; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | ▶ | my $level = $link_style =~ /^([0-9]+)-level$/ ? int($1): 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | my $filename = File::Spec->catfile(( map {$up} 0 .. $level), 'store', $dbname); | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | foreach my $fn ($self->_linknames($digests, $link_style)) { | |||||||||||||||||||||||||||||||||||||||||
| 224 | 20 | ▶ | next if -l $fn; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 10 | ▶ | symlink($filename, $fn) or croak $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | my $used_digests_ni = $self->_used_digests_ni; | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | ▶ | if (scalar(@{$used_digests_ni})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | state $up = File::Spec->updir; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $dbname = $self->dbname; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $filename = File::Spec->catfile(( map {$up} 0..1), 'store', $dbname); | |||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | foreach my $digest (@{$used_digests_ni}) { | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $v = $digests->{$digest} // next; # TODO: Try to query it! | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$digests->{$digest} // (next)
MC/DC0%0/1
$digests->{$digest} // (next)
$digests->{$digest}
Truth table0%0/2
A
A= $digests->{$digest}
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my $fn = $store->_file(v2 => ni => ($File::FStore::_ni_hashes{$digest} // next) => MIME::Base64::encode_base64url(pack('H*', $v))); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$File::FStore::_ni_hashes{$digest} // (next)
MC/DC0%0/1
$File::FStore::_ni_hashes{$digest} // (next)
$File::FStore::_ni_hashes{$digest}
Truth table0%0/2
A
A= $File::FStore::_ni_hashes{$digest}
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | next if -l $fn; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | symlink($filename, $fn) or croak $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | ▶ | if (defined(my $handle = File::FStore::File::_DUMMY_FOR_XATTR->new($fh))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if (defined($properties->{size}) && !defined($handle->getfattr('utag.final.file.size'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $properties->{"size"} and not defined $handle->getfattr("utag.final.file.size")
MC/DC0%0/2
defined $properties->{"size"} and not defined $handle->getfattr("utag.final.file.size")
defined $properties->{"size"}
not defined $handle->getfattr("utag.final.file.size")
Truth table0%0/3
A and not(B)
A= defined $properties->{"size"}B= not defined $handle->getfattr("utag.final.file.size")
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $handle->setfattr('utag.final.file.size' => $properties->{size}); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (defined($properties->{mediasubtype}) && !defined($handle->getfattr('mime_type'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $properties->{"mediasubtype"} and not defined $handle->getfattr("mime_type")
MC/DC0%0/2
defined $properties->{"mediasubtype"} and not defined $handle->getfattr("mime_type")
defined $properties->{"mediasubtype"}
not defined $handle->getfattr("mime_type")
Truth table0%0/3
A and not(B)
A= defined $properties->{"mediasubtype"}B= not defined $handle->getfattr("mime_type")
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $handle->setfattr('mime_type' => $properties->{mediasubtype}); | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if (defined($properties->{mediasubtype}) && !defined($handle->getfattr('utag.final.file.encoding'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $properties->{"mediasubtype"} and not defined $handle->getfattr("utag.final.file.encoding")
MC/DC0%0/2
defined $properties->{"mediasubtype"} and not defined $handle->getfattr("utag.final.file.encoding")
defined $properties->{"mediasubtype"}
not defined $handle->getfattr("utag.final.file.encoding")
Truth table0%0/3
A and not(B)
A= defined $properties->{"mediasubtype"}B= not defined $handle->getfattr("utag.final.file.encoding")
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | my $v = Data::Identifier::Generate->generic( | ||||||||||||||||||||||||||||||||||||||||||
| 259 | namespace => '50d7c533-2d9b-4208-b560-bcbbf75ce3f9', | ||||||||||||||||||||||||||||||||||||||||||
| 260 | input => $properties->{mediasubtype}, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | )->uuid; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $handle->setfattr('utag.final.file.encoding' => $v); | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (!defined($handle->getfattr('utag.write-mode'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $handle->setfattr('utag.write-mode' => '7b177183-083c-4387-abd3-8793eb647373'); | |||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if (!defined($handle->getfattr('utag.final-mode'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $handle->setfattr('utag.final-mode' => 'f418cdb9-64a7-4f15-9a18-63f7755c5b47'); | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | if (defined(my $size = $properties->{size}) && !defined($handle->getfattr('utag.final.file.hash'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined(my $size = $properties->{"size"}) and not defined $handle->getfattr("utag.final.file.hash")
MC/DC0%0/2
defined(my $size = $properties->{"size"}) and not defined $handle->getfattr("utag.final.file.hash")
defined(my $size = $properties->{"size"})
not defined $handle->getfattr("utag.final.file.hash")
Truth table0%0/3
A and not(B)
A= defined(my $size = $properties->{"size"})B= not defined $handle->getfattr("utag.final.file.hash")
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my @el; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $v = ''; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | foreach my $algo (@_xattr_hashes) { | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | push(@el, sprintf(' %s bytes 0-%u/%u %s', $algo, $size - 1, $size, $digests->{$algo} // next)); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$digests->{$algo} // (next)
MC/DC0%0/1
$digests->{$algo} // (next)
$digests->{$algo}
Truth table0%0/2
A
A= $digests->{$algo}
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | for (my $i = 0; $i < scalar(@el); $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | $v .= ' ' if $i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | $v .= $i == $#el ? 'v0' : 'v0m'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $v .= $el[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | $handle->setfattr('utag.final.file.hash' => $v) if length $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | # Try to alter the file mode to make the file read only. | ||||||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, | |||||||||||||||||||||||||||||||||||||||||
| 294 | $atime,$mtime,$ctime,$blksize,$blocks) = $self->stat; | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | ▶ | if (defined($mode) && ($mode & WRITE_BITS)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $mode and $mode & 146
MC/DC50%1/2
defined $mode and $mode & 146
defined $mode
$mode & 146
Truth table66%2/3
A and B
A= defined $modeB= $mode & 146
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | my $n = $mode & (07777 ^ WRITE_BITS); | |||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | eval { chmod($n, $fh) }; # we don't care if it fails. | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | ▶ | $on_post_set->($self) if defined $on_post_set; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 6 | ▶ | sub stat { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stat: called CC=4 SCAR=14.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 6 | ▶ | $self->{stat} //= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"stat"} //= do {
my @s;
if (defined $self->{"fh"}) {
@s = CORE::stat $self->{"fh"};
}
else {
@s = CORE::stat $self->filename;
};
croak('File missing on filesystem, store is corruped: ' . $self->dbname) unless scalar @s;
\@s
}
MC/DC0%0/2
$self->{"stat"} //= do {
my @s;
if (defined $self->{"fh"}) {
@s = CORE::stat $self->{"fh"};
}
else {
@s = CORE::stat $self->filename;
};
croak('File missing on filesystem, store is corruped: ' . $self->dbname) unless scalar @s;
\@s
}
$self->{"stat"}
do {
my @s;
if (defined $self->{"fh"}) {
@s = CORE::stat $self->{"fh"};
}
else {
@s = CORE::stat $self->filename;
};
croak('File missing on filesystem, store is corruped: ' . $self->dbname) unless scalar @s;
\@s
}
Truth table66%2/3
A //= B
A= $self->{"stat"}B= do {
my @s;
if (defined $self->{"fh"}) {
@s = CORE::stat $self->{"fh"};
}
else {
@s = CORE::stat $self->filename;
};
croak('File missing on filesystem, store is corruped: ' . $self->dbname) unless scalar @s;
\@s
}
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 4 | my @s; | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 4 | ▶ | if (defined $self->{fh}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 4 | @s = stat($self->{fh}); | |||||||||||||||||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | @s = stat($self->filename); | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 4 | ▶ | croak 'File missing on filesystem, store is corruped: '.$self->dbname unless scalar(@s); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 4 | \@s; | |||||||||||||||||||||||||||||||||||||||||
| 322 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 6 | return @{$self->{stat}}; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 16 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=11 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 16 | my ($self, $domain, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 16 | ▶ | if (defined($domain)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 14 | ▶ | if (defined($key)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 10 | my $sth; | |||||||||||||||||||||||||||||||||||||||||
| 333 | my $res; | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 10 | ▶ | if ($domain eq 'properties') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 6 | $sth = $self->_prepare('SELECT value FROM file_properties WHERE file = ? AND key = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 337 | } elsif ($domain eq 'digests') { | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 4 | $sth = $self->_prepare('SELECT hash FROM file_hash WHERE file = ? AND algo = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 10 | ▶ | croak 'Invalid domain: '.$domain unless defined $sth; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 10 | $sth->execute($self->{dbid}, $key); | |||||||||||||||||||||||||||||||||||||||||
| 344 | 10 | $res = $sth->fetchall_arrayref; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 10 | ▶ | return $res->[0][0] // croak 'No value for domain '.$domain.' key '.$key; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$res->[0][0] // croak('No value for domain ' . $domain . ' key ' . $key)
MC/DC100%1/1
$res->[0][0] // croak('No value for domain ' . $domain . ' key ' . $key)
$res->[0][0]
Truth table100%2/2
A
A= $res->[0][0]
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 4 | my $sth; | |||||||||||||||||||||||||||||||||||||||||
| 349 | my %res; | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 4 | ▶ | if ($domain eq 'properties') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 2 | $sth = $self->_prepare('SELECT key,value FROM file_properties WHERE file = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 353 | } elsif ($domain eq 'digests') { | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | $sth = $self->_prepare('SELECT algo,hash FROM file_hash WHERE file = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | ▶ | croak 'Invalid domain: '.$domain unless defined $sth; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 4 | $sth->execute($self->{dbid}); | |||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 4 | ▶ | while (my $row = $sth->fetchrow_arrayref) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 26 | $res{$row->[0]} = $row->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 4 | return \%res; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 2 | return {map {$_ => $self->get($_)} qw(properties digests)}; | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | my ($self, $domain, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | my $dbid = $self->{dbid}; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 4 | ▶ | croak 'No data given' unless defined $domain; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | # get things in standard format: | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 4 | ▶ | if (defined($key)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $data = {$domain => {$key => $value}}; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $data = {$domain => $key}; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 4 | $data = $domain; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 4 | ▶ | $self->store->in_transaction(rw => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 4 | foreach my $cdomain (keys %{$data}) { | |||||||||||||||||||||||||||||||||||||||||
| 393 | 7 | my $d = $data->{$cdomain}; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 7 | my $sth; | |||||||||||||||||||||||||||||||||||||||||
| 395 | my $valids; | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 7 | ▶ | if ($cdomain eq 'properties') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 4 | $sth = $self->_prepare('INSERT INTO file_properties (file,key,value) SELECT ?, ?, ? WHERE NOT EXISTS (SELECT TRUE FROM file_properties WHERE file = ? AND key = ? AND value = ?)'); | |||||||||||||||||||||||||||||||||||||||||
| 399 | 4 | $valids = \%_valid_properties; | |||||||||||||||||||||||||||||||||||||||||
| 400 | } elsif ($cdomain eq 'digests') { | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | $sth = $self->_prepare('INSERT INTO file_hash (file,algo,hash) SELECT ?, ?, ? WHERE NOT EXISTS (SELECT TRUE FROM file_hash WHERE file = ? AND algo = ? AND hash = ?)'); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | $valids = $self->_valid_digests; | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 7 | ▶ | croak 'Invalid domain: '.$domain unless defined $sth; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 7 | foreach my $key (keys %{$d}) { | |||||||||||||||||||||||||||||||||||||||||
| 408 | 40 | ▶ | croak 'Invalid key '.$key.' for domain '.$cdomain unless defined $valids->{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 40 | ▶ | croak 'Invalid value for key '.$key.' for domain '.$cdomain unless $d->{$key} =~ $valids->{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 40 | $sth->execute($dbid, $key, $d->{$key}, $dbid, $key, $d->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 4 | }); | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $store = $self->store; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | my $dbid = $self->{dbid} or croak 'Call on invalid object'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | $store->in_transaction(rw => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $filename = $self->filename; | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my @linknames = $self->_linknames(undef, 'all'); | |||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $sth; | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | unlink($filename) or croak 'Cannot unlink file: '.$!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | unlink($_) foreach @linknames; | |||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $sth = $self->_prepare('DELETE FROM file_hash WHERE file = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $sth->execute($dbid); | |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $sth = $self->_prepare('DELETE FROM file_properties WHERE file = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $sth->execute($dbid); | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $sth = $self->_prepare('DELETE FROM file WHERE id = ?'); | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $sth->execute($dbid); | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | %{$self} = (); | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub sync_with_db { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sync_with_db: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | my $db = $opts{db} // $self->store->so_get('db', default => undef, no_defaults => 1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"db"} // $self->store->so_get("db", "default", undef, "no_defaults", 1)
MC/DC0%0/2
$opts{"db"} // $self->store->so_get("db", "default", undef, "no_defaults", 1)
$opts{"db"}
$self->store->so_get("db", "default", undef, "no_defaults", 1)
Truth table0%0/3
A // B
A= $opts{"db"}B= $self->store->so_get("db", "default", undef, "no_defaults", 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $fii_inode = $self->as('File::Information::Inode'); | |||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | $db->in_transaction(rw => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=22 SCAR=62.3
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||
| 448 | my %ids = ( | ||||||||||||||||||||||||||||||||||||||||||
| 449 | contentise => $self->contentise(as => 'Data::Identifier'), | ||||||||||||||||||||||||||||||||||||||||||
| 450 | inodeise => $fii_inode->get('inodeise', as => 'Data::Identifier', default => undef), | ||||||||||||||||||||||||||||||||||||||||||
| 451 | proto => (defined($opts{proto}) ? $opts{proto}->Data::Identifier::as('Data::Identifier') : undef), | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | # Related values: | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | encoding => (defined($data->{properties}{mediasubtype}) ? Data::Identifier::Generate->generic( | ||||||||||||||||||||||||||||||||||||||||||
| 456 | namespace => '50d7c533-2d9b-4208-b560-bcbbf75ce3f9', | ||||||||||||||||||||||||||||||||||||||||||
| 457 | input => $data->{properties}{mediasubtype}, | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | ): undef), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | %_db_tags, | ||||||||||||||||||||||||||||||||||||||||||
| 461 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my %tags = map {$_ => scalar(eval {$ids{$_}->as('Data::TagDB::Tag', %opts{autocreate}, db => $db)})} grep {defined $ids{$_}} keys %ids; | |||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | if (defined(my $tag = $tags{contentise})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my $size = $data->{properties}{size}; | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if (defined($tags{also_has_role}) && defined($tags{specific_proto_file_state})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tags{"also_has_role"} and defined $tags{"specific_proto_file_state"}
MC/DC0%0/2
defined $tags{"also_has_role"} and defined $tags{"specific_proto_file_state"}
defined $tags{"also_has_role"}
defined $tags{"specific_proto_file_state"}
Truth table0%0/3
A and B
A= defined $tags{"also_has_role"}B= defined $tags{"specific_proto_file_state"}
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $db->create_relation(tag => $tag, relation => $tags{also_has_role}, related => $tags{specific_proto_file_state}); | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | if (defined($size) && defined($tags{final_file_size})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $size and defined $tags{"final_file_size"}
MC/DC0%0/2
defined $size and defined $tags{"final_file_size"}
defined $size
defined $tags{"final_file_size"}
Truth table0%0/3
A and B
A= defined $sizeB= defined $tags{"final_file_size"}
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $db->create_metadata(tag => $tag, relation => $tags{final_file_size}, data_raw => $size); | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | if (defined($tags{encoding}) && defined($tags{final_file_encoding})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tags{"encoding"} and defined $tags{"final_file_encoding"}
MC/DC0%0/2
defined $tags{"encoding"} and defined $tags{"final_file_encoding"}
defined $tags{"encoding"}
defined $tags{"final_file_encoding"}
Truth table0%0/3
A and B
A= defined $tags{"encoding"}B= defined $tags{"final_file_encoding"}
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $db->create_relation(tag => $tag, relation => $tags{final_file_encoding}, related => $tags{encoding}); | |||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | if (defined($tags{final_file_hash}) && defined($size) && $size > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $tags{"final_file_hash"} and defined $size and $size > 0
defined $tags{"final_file_hash"} and defined $size
MC/DC0%0/3
defined $tags{"final_file_hash"} and defined $size and $size > 0
defined $tags{"final_file_hash"}
defined $size
$size > 0
Truth table0%0/4
A and B and C
A= defined $tags{"final_file_hash"}B= defined $sizeC= $size > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | foreach my $digest (keys %{$data->{digests}}) { | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | my $v = sprintf('v0 %s bytes 0-%u/%u %s', $digest, $size - 1, $size, $data->{digests}{$digest} // next); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data->{"digests"}{$digest} // (next)
MC/DC0%0/1
$data->{"digests"}{$digest} // (next)
$data->{"digests"}{$digest}
Truth table0%0/2
A
A= $data->{"digests"}{$digest}
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $db->create_metadata(tag => $tag, relation => $tags{final_file_hash}, data_raw => $v); | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | if (defined(my $proto = $tags{proto})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if (defined(my $tag = $tags{contentise})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if (defined(my $relation = $opts{final_of_proto} ? $tags{has_final_state} : $tags{also_has_state})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $db->create_relation(tag => $proto, relation => $relation, related => $tag); | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if (defined(my $inode = $tags{inodeise})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if (defined(my $tag = $tags{contentise})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | if (defined($tags{has_final_state})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $db->create_relation(tag => $inode, relation => $tags{has_final_state}, related => $tag); | |||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | # --- Overrides for Data::URIID::Base --- | ||||||||||||||||||||||||||||||||||||||||||
| 507 | 1 | ▶ | sub contentise { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contentise: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | ▶ | $self->{contentise} //= eval {Data::Identifier->new(ise => $self->get(properties => 'contentise'))}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"contentise"} //= eval {
do {
"Data::Identifier"->new("ise", $self->get("properties", "contentise"))
}
}
MC/DC0%0/2
$self->{"contentise"} //= eval {
do {
"Data::Identifier"->new("ise", $self->get("properties", "contentise"))
}
}
$self->{"contentise"}
eval {
do {
"Data::Identifier"->new("ise", $self->get("properties", "contentise"))
}
}
Truth table33%1/3
A //= B
A= $self->{"contentise"}B= eval {
do {
"Data::Identifier"->new("ise", $self->get("properties", "contentise"))
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | ▶ | $self->{contentise} //= $self->_calculate_contentise; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"contentise"} //= $self->_calculate_contentise
MC/DC0%0/2
$self->{"contentise"} //= $self->_calculate_contentise
$self->{"contentise"}
$self->_calculate_contentise
Truth table33%1/3
A //= B
A= $self->{"contentise"}B= $self->_calculate_contentise
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 1 | return $self->SUPER::contentise(@args); | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 3 | ▶ | sub as { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as: called CC=8 SCAR=28.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 3 | my ($self, $as, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | ▶ | if ($as eq 'File::Information::Inode' || $as eq 'File::Information::Base') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$as eq "File::Information::Inode" or $as eq "File::Information::Base"
MC/DC50%1/2
$as eq "File::Information::Inode" or $as eq "File::Information::Base"
$as eq "File::Information::Inode"
$as eq "File::Information::Base"
Truth table66%2/3
A or B
A= $as eq "File::Information::Inode"B= $as eq "File::Information::Base"
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 2 | ▶ | if (defined $opts{fii}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | return $opts{fii}->for_handle($self->_open); | |||||||||||||||||||||||||||||||||||||||||
| 522 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 2 | ▶ | return $self->{fii_inode} //= $self->fii->for_handle($self->_open); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"fii_inode"} //= $self->fii->for_handle($self->_open)
MC/DC0%0/2
$self->{"fii_inode"} //= $self->fii->for_handle($self->_open)
$self->{"fii_inode"}
$self->fii->for_handle($self->_open)
Truth table33%1/3
A //= B
A= $self->{"fii_inode"}B= $self->fii->for_handle($self->_open)
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } elsif ($as eq 'File::Information::Link') { | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | if (defined $opts{fii}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | return $opts{fii}->for_link($self->filename); | |||||||||||||||||||||||||||||||||||||||||
| 528 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | return $self->{fii_inode} //= $self->fii->for_link($self->filename); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"fii_inode"} //= $self->fii->for_link($self->filename)
MC/DC0%0/2
$self->{"fii_inode"} //= $self->fii->for_link($self->filename)
$self->{"fii_inode"}
$self->fii->for_link($self->filename)
Truth table0%0/3
A //= B
A= $self->{"fii_inode"}B= $self->fii->for_link($self->filename)
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | return $self->SUPER::as($as, %opts); | |||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | # --- Overrides for Data::Identifier::Interface::Known --- | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | sub _known_provider { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_known_provider: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my ($pkg, $class, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | state $classes = { | |||||||||||||||||||||||||||||||||||||||||
| 541 | properties => [[keys %_valid_properties], not_identifiers => 1], | ||||||||||||||||||||||||||||||||||||||||||
| 542 | digests => [[keys %File::FStore::_valid_digests], not_identifiers => 1], | ||||||||||||||||||||||||||||||||||||||||||
| 543 | link_styles => [[keys %File::FStore::_valid_link_styles], not_identifiers => 1], | ||||||||||||||||||||||||||||||||||||||||||
| 544 | store_styles => [[keys %File::FStore::_valid_store_styles], not_identifiers => 1], | ||||||||||||||||||||||||||||||||||||||||||
| 545 | domains => [[qw(properties digests)], not_identifiers => 1], | ||||||||||||||||||||||||||||||||||||||||||
| 546 | mediasubtypes => [\@_media_subtypes, rawtype => 'Data::Identifier'], | ||||||||||||||||||||||||||||||||||||||||||
| 547 | other_tags => [[values %_db_tags], rawtype => 'Data::Identifier'], | ||||||||||||||||||||||||||||||||||||||||||
| 548 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | croak 'Unsupported options passed' if scalar(keys %opts); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $class =~ tr/-/_/; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | return @{$classes->{$class}} if defined $classes->{$class}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | return ([map {@{$_->[0]}} values %{$classes}], not_identifiers => 1) if $class eq ':all'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | croak 'Unsupported class'; | |||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 3 | ▶ | sub _valid_digests { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_digests: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 3 | return state $digests = {map {$_ => qr/^[0-9a-f]{$File::FStore::_valid_digests{$_}}$/} keys %File::FStore::_valid_digests}; | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 3 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 565 | 3 | my $self = $pkg->SUPER::_new(%opts); | |||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 3 | ▶ | croak 'No dbid is given' unless defined $self->{dbid}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 23 | ▶ | sub _prepare { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | 23 | my ($self, $q) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 23 | ▶ | my $dbh = $self->{dbh} //= $self->store->{dbh}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"dbh"} //= $self->store->{"dbh"}
MC/DC0%0/2
$self->{"dbh"} //= $self->store->{"dbh"}
$self->{"dbh"}
$self->store->{"dbh"}
Truth table66%2/3
A //= B
A= $self->{"dbh"}B= $self->store->{"dbh"}
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 23 | return $dbh->prepare($q); | |||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 6 | ▶ | sub _open { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_open: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 6 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 580 | 6 | my $fh; | |||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 6 | ▶ | $self->{fh} = $opts{fh} if defined $opts{fh}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 6 | ▶ | $fh = $self->{fh} //= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"fh"} //= do {
CORE::open my $in, "<", $self->filename or croak($!);
$in
}
MC/DC0%0/2
$self->{"fh"} //= do {
CORE::open my $in, "<", $self->filename or croak($!);
$in
}
$self->{"fh"}
do {
CORE::open my $in, "<", $self->filename or croak($!);
$in
}
Truth table66%2/3
A //= B
A= $self->{"fh"}B= do {
CORE::open my $in, "<", $self->filename or croak($!);
$in
}
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 3 | ▶ | CORE::open(my $in, '<', $self->filename) or croak $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | 3 | $in; | |||||||||||||||||||||||||||||||||||||||||
| 587 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | 6 | ▶ | seek($fh, 0, SEEK_SET) or croak $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 6 | return $fh; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | ▶ | sub _detach_fh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detach_fh: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | $self->{fh} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 5 | ▶ | sub _used_digests { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_used_digests: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 601 | 5 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | 5 | ▶ | sub _used_digests_ni { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_used_digests_ni: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 606 | 5 | ▶ | return $self->{used_digests_ni} //= $self->store->_used_digests_ni; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"used_digests_ni"} //= $self->store->_used_digests_ni
MC/DC0%0/2
$self->{"used_digests_ni"} //= $self->store->_used_digests_ni
$self->{"used_digests_ni"}
$self->store->_used_digests_ni
Truth table66%2/3
A //= B
A= $self->{"used_digests_ni"}B= $self->store->_used_digests_ni
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | ▶ | sub _calculate_contentise { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_calculate_contentise: called CC=10 SCAR=27.3
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 2 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 611 | 2 | my $sha_1_160 = eval { $self->get(digests => 'sha-1-160') }; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 2 | my $sha_3_512 = eval { $self->get(digests => 'sha-3-512') }; | |||||||||||||||||||||||||||||||||||||||||
| 613 | 2 | my $size = eval { $self->get(properties => 'size') }; | |||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 2 | ▶ | if (defined $data) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 2 | ▶ | $data->{digests} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"digests"} //= {}
MC/DC0%0/1
$data->{"digests"} //= {}
$data->{"digests"}
Truth table50%1/2
A
A= $data->{"digests"}
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 2 | ▶ | $data->{properties} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{"properties"} //= {}
MC/DC0%0/1
$data->{"properties"} //= {}
$data->{"properties"}
Truth table50%1/2
A
A= $data->{"properties"}
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | 2 | ▶ | $sha_1_160 //= $data->{digests}{'sha-1-160'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$sha_1_160 //= $data->{"digests"}{"sha-1-160"}
MC/DC0%0/2
$sha_1_160 //= $data->{"digests"}{"sha-1-160"}
$sha_1_160
$data->{"digests"}{"sha-1-160"}
Truth table33%1/3
A //= B
A= $sha_1_160B= $data->{"digests"}{"sha-1-160"}
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 2 | ▶ | $sha_3_512 //= $data->{digests}{'sha-3-512'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$sha_3_512 //= $data->{"digests"}{"sha-3-512"}
MC/DC0%0/2
$sha_3_512 //= $data->{"digests"}{"sha-3-512"}
$sha_3_512
$data->{"digests"}{"sha-3-512"}
Truth table33%1/3
A //= B
A= $sha_3_512B= $data->{"digests"}{"sha-3-512"}
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | 2 | ▶ | $size //= $data->{properties}{size}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$size //= $data->{"properties"}{"size"}
MC/DC0%0/2
$size //= $data->{"properties"}{"size"}
$size
$data->{"properties"}{"size"}
Truth table33%1/3
A //= B
A= $sizeB= $data->{"properties"}{"size"}
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | 2 | ▶ | if (defined($sha_1_160) && defined($sha_3_512) && defined($size)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $sha_1_160 and defined $sha_3_512 and defined $size
defined $sha_1_160 and defined $sha_3_512
MC/DC0%0/3
defined $sha_1_160 and defined $sha_3_512 and defined $size
defined $sha_1_160
defined $sha_3_512
defined $size
Truth table25%1/4
A and B and C
A= defined $sha_1_160B= defined $sha_3_512C= defined $size
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 2 | my $digest = sprintf('v0m sha-1-160 bytes 0-%u/%u %s v0 sha-3-512 bytes 0-%u/%u %s', | |||||||||||||||||||||||||||||||||||||||||
| 625 | $size - 1, $size, $sha_1_160, | ||||||||||||||||||||||||||||||||||||||||||
| 626 | $size - 1, $size, $sha_3_512, | ||||||||||||||||||||||||||||||||||||||||||
| 627 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | return Data::Identifier::Generate->generic( | |||||||||||||||||||||||||||||||||||||||||
| 630 | namespace => '66d488c0-3b19-4e6c-856f-79edf2484f37', | ||||||||||||||||||||||||||||||||||||||||||
| 631 | input => $digest, | ||||||||||||||||||||||||||||||||||||||||||
| 632 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | 2 | ▶ | sub _ext { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ext: called CC=6 SCAR=21.5
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | 2 | ▶ | return $self->{ext} if exists $self->{ext}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | { | ||||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | ▶ | my $mediasubtype = eval {$self->get(properties => 'mediasubtype')} // 'x.x/x.x'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
$self->get("properties", "mediasubtype")
}
} // "x.x/x.x"
MC/DC0%0/1
eval {
do {
$self->get("properties", "mediasubtype")
}
} // "x.x/x.x"
eval {
do {
$self->get("properties", "mediasubtype")
}
}
Truth table50%1/2
A
A= eval {
do {
$self->get("properties", "mediasubtype")
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 2 | ▶ | return $self->{ext} = $_exts{$mediasubtype} if defined $_exts{$mediasubtype}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | { | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 2 | my $dbname = $self->dbname; | |||||||||||||||||||||||||||||||||||||||||
| 649 | 2 | ▶ | if ($dbname =~ /\.([a-z0-9]{1,4})$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $ext = $1; | |||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | if ($dbname =~ /\.(tar\.(?:gz|bz2|xz|lz|zst))$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $ext = $1; | |||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | return $self->{ext} = $ext; | |||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | 2 | return $self->{ext} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 2 | ▶ | sub _linknames { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_linknames: called CC=11 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 2 | my ($self, $digests, $link_style) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 665 | 2 | my File::FStore $store = $self->store; | |||||||||||||||||||||||||||||||||||||||||
| 666 | 2 | my $ext = $self->_ext; | |||||||||||||||||||||||||||||||||||||||||
| 667 | 2 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 2 | ▶ | $ext = '.'.$ext if defined $ext; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 2 | ▶ | $digests //= $self->get('digests'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$digests //= $self->get("digests")
MC/DC0%0/2
$digests //= $self->get("digests")
$digests
$self->get("digests")
Truth table33%1/3
A //= B
A= $digestsB= $self->get("digests")
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | 2 | ▶ | $link_style //= $store->setting('link_style'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$link_style //= $store->setting("link_style")
MC/DC0%0/2
$link_style //= $store->setting("link_style")
$link_style
$store->setting("link_style")
Truth table33%1/3
A //= B
A= $link_styleB= $store->setting("link_style")
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 2 | foreach my $digest (@{$self->_used_digests}) { | |||||||||||||||||||||||||||||||||||||||||
| 675 | 20 | ▶ | my $v = $digests->{$digest} // next; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$digests->{$digest} // (next)
MC/DC0%0/1
$digests->{$digest} // (next)
$digests->{$digest}
Truth table50%1/2
A
A= $digests->{$digest}
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 20 | ▶ | $v .= $ext if defined $ext; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 20 | ▶ | if ($link_style eq '1-level' || $link_style eq 'all') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$link_style eq "1-level" or $link_style eq "all"
MC/DC0%0/2
$link_style eq "1-level" or $link_style eq "all"
$link_style eq "1-level"
$link_style eq "all"
Truth table33%1/3
A or B
A= $link_style eq "1-level"B= $link_style eq "all"
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | 20 | push(@res, $store->_file(v2 => by => $digest => $v)); | |||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 20 | ▶ | if ($link_style eq '2-level' || $link_style eq 'all') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$link_style eq "2-level" or $link_style eq "all"
MC/DC0%0/2
$link_style eq "2-level" or $link_style eq "all"
$link_style eq "2-level"
$link_style eq "all"
Truth table33%1/3
A or B
A= $link_style eq "2-level"B= $link_style eq "all"
| |||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | push(@res, $store->_file(v2 => by => $digest => substr($v, 0, 2) => $v)); | |||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 2 | return @res; | |||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | # Bad workaround for File::ExtAttr | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 3 | package File::FStore::File::_DUMMY_FOR_XATTR { | |||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 2 | my ($pkg, $fh) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | return undef unless eval {require File::ExtAttr; File::ExtAttr->import; 1;}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | return bless \$fh; | |||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | sub isa { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | my ($self, $pkg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | return 1 if $pkg eq 'IO::Handle'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | return $self->SUPER::isa($pkg); | |||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | sub fileno { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileno: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | return ${$self}->fileno; | |||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | sub getfattr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getfattr: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | return eval { $self->File::ExtAttr::getfattr($key, { namespace => 'user' }) }; | |||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | sub setfattr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setfattr: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | return eval { $self->File::ExtAttr::setfattr($key => $value, { namespace => 'user' }) }; | |||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||
| 720 | __END__ | ||||||||||||||||||||||||||||||||||||||||||