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