| 1 | # Copyright (c) 2024-2026 Philipp Schafft <lion@cpan.org> | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||||
| 4 | |||||||||||||||||||||||
| 5 | # ABSTRACT: generic module for extracting information from filesystems | ||||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | package File::Information::Remote; | ||||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 1 | ▶ | use v5.10; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | 1 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 1 | ▶ | use parent 'File::Information::Base'; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | 1 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 17 | |||||||||||||||||||||||
| 18 | 1 | our $VERSION = v0.17; | |||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 1 | my %_properties = ( | |||||||||||||||||||||
| 21 | data_uriid_attr_displayname => {loader => \&_load_data_uriid}, | ||||||||||||||||||||||
| 22 | data_uriid_attr_media_subtype => {loader => \&_load_data_uriid, rawtype => 'mediatype'}, | ||||||||||||||||||||||
| 23 | data_uriid_attr_thumbnail => {loader => \&_load_data_uriid}, | ||||||||||||||||||||||
| 24 | data_uriid_id => {loader => \&_load_data_uriid}, | ||||||||||||||||||||||
| 25 | data_uriid_ise => {loader => \&_load_data_uriid, rawtype => 'ise'}, | ||||||||||||||||||||||
| 26 | data_uriid_type => {loader => \&_load_data_uriid, rawtype => 'ise'}, | ||||||||||||||||||||||
| 27 | data_uriid_result => {loader => \&_load_data_uriid, rawtype => 'Data::URIID::Result'}, | ||||||||||||||||||||||
| 28 | store_file => {loader => \&_load_fstore, rawtype => 'File::FStore::File'}, | ||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||
| 30 | |||||||||||||||||||||||
| 31 | # ---------------- | ||||||||||||||||||||||
| 32 | |||||||||||||||||||||||
| 33 | 0 | ▶ | sub _new { | ||||||||||||||||||||
|
Subroutine
_new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 34 | 0 | my ($pkg, %opts) = @_; | |||||||||||||||||||||
| 35 | 0 | my $self = $pkg->SUPER::_new(%opts, properties => \%_properties); | |||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | 0 | return $self; | |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||
| 39 | |||||||||||||||||||||||
| 40 | 0 | ▶ | sub _load_data_uriid { | ||||||||||||||||||||
|
Subroutine
_load_data_uriid: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||
| 41 | 0 | my ($self) = @_; | |||||||||||||||||||||
| 42 | 0 | ▶ | my $result = $self->{data_uriid_result} // return; | ||||||||||||||||||||
|
Condition0%0/2
$self->{"data_uriid_result"} // (return)
MC/DC0%0/1
$self->{"data_uriid_result"} // (return)
$self->{"data_uriid_result"}
Truth table0%0/2
A
A= $self->{"data_uriid_result"}
| |||||||||||||||||||||||
| 43 | 0 | ▶ | my $pv = ($self->{properties_values} //= {})->{current} //= {}; | ||||||||||||||||||||
|
Condition0%0/4
+($self->{"properties_values"} //= {})->{"current"} //= {}
$self->{"properties_values"} //= {}
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"current"} //= {}
+($self->{"properties_values"} //= {})->{"current"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table0%0/2
A
A= +($self->{"properties_values"} //= {})->{"current"}
Truth table0%0/2
A
A= $self->{"properties_values"}
| |||||||||||||||||||||||
| 44 | |||||||||||||||||||||||
| 45 | 0 | ▶ | return if $self->{_loaded_data_uriid}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 46 | 0 | $self->{_loaded_data_uriid} = 1; | |||||||||||||||||||||
| 47 | |||||||||||||||||||||||
| 48 | 0 | eval {$pv->{data_uriid_ise} = {raw => $result->ise}}; | |||||||||||||||||||||
| 49 | 0 | eval {$pv->{data_uriid_id} = {raw => $result->id}}; | |||||||||||||||||||||
| 50 | 0 | eval {$pv->{data_uriid_type} = {raw => $result->id_type(as => 'ise')}}; | |||||||||||||||||||||
| 51 | 0 | $pv->{data_uriid_result} = {raw => $result}; | |||||||||||||||||||||
| 52 | |||||||||||||||||||||||
| 53 | 0 | foreach my $digest ($result->available_keys('digest')) { | |||||||||||||||||||||
| 54 | 0 | ▶ | my $value = $result->digest($digest, as => 'hex', default => undef) // next; | ||||||||||||||||||||
|
Condition0%0/2
$result->digest($digest, "as", "hex", "default", undef) // (next)
MC/DC0%0/1
$result->digest($digest, "as", "hex", "default", undef) // (next)
$result->digest($digest, "as", "hex", "default", undef)
Truth table0%0/2
A
A= $result->digest($digest, "as", "hex", "default", undef)
| |||||||||||||||||||||||
| 55 | 0 | $self->{digest}{current}{$digest} = $value; | |||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||
| 57 | |||||||||||||||||||||||
| 58 | 0 | foreach my $key (grep {/^data_uriid_attr_/} keys %_properties) { | |||||||||||||||||||||
| 59 | 0 | my $real_key = $key =~ s/^data_uriid_attr_//r; | |||||||||||||||||||||
| 60 | 0 | ▶ | my $value = $result->attribute($real_key, as => 'string', default => undef) // next; | ||||||||||||||||||||
|
Condition0%0/2
$result->attribute($real_key, "as", "string", "default", undef) // (next)
MC/DC0%0/1
$result->attribute($real_key, "as", "string", "default", undef) // (next)
$result->attribute($real_key, "as", "string", "default", undef)
Truth table0%0/2
A
A= $result->attribute($real_key, "as", "string", "default", undef)
| |||||||||||||||||||||||
| 61 | 0 | $pv->{$key} = {raw => $value}; | |||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||
| 64 | |||||||||||||||||||||||
| 65 | 0 | ▶ | sub _load_fstore { | ||||||||||||||||||||
|
Subroutine
_load_fstore: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||
| 66 | 0 | my ($self, $key, %opts) = @_; | |||||||||||||||||||||
| 67 | 0 | my $ise; | |||||||||||||||||||||
| 68 | my @candidates; | ||||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | 0 | ▶ | return if $self->{_loaded_fstore}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 71 | 0 | $self->{_loaded_fstore} = 1; | |||||||||||||||||||||
| 72 | |||||||||||||||||||||||
| 73 | 0 | $ise = $self->get('data_uriid_ise', default => undef); | |||||||||||||||||||||
| 74 | |||||||||||||||||||||||
| 75 | 0 | ▶ | return unless defined $ise;; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 76 | |||||||||||||||||||||||
| 77 | 0 | foreach my $store ($self->instance->store(as => 'File::FStore')) { | |||||||||||||||||||||
| 78 | 0 | push(@candidates, $store->query(ise => $ise)); | |||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||
| 80 | |||||||||||||||||||||||
| 81 | 0 | ▶ | if (scalar(@candidates)) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 82 | 0 | ▶ | my $pv_current = ($self->{properties_values} //= {})->{current} //= {}; | ||||||||||||||||||||
|
Condition0%0/4
+($self->{"properties_values"} //= {})->{"current"} //= {}
$self->{"properties_values"} //= {}
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"current"} //= {}
+($self->{"properties_values"} //= {})->{"current"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table0%0/2
A
A= +($self->{"properties_values"} //= {})->{"current"}
Truth table0%0/2
A
A= $self->{"properties_values"}
| |||||||||||||||||||||||
| 83 | 0 | ▶ | my $pv_final = ($self->{properties_values} //= {})->{final} //= {}; | ||||||||||||||||||||
|
Condition0%0/4
+($self->{"properties_values"} //= {})->{"final"} //= {}
$self->{"properties_values"} //= {}
MC/DC0%0/1
+($self->{"properties_values"} //= {})->{"final"} //= {}
+($self->{"properties_values"} //= {})->{"final"}
MC/DC0%0/1
$self->{"properties_values"} //= {}
$self->{"properties_values"}
Truth table0%0/2
A
A= +($self->{"properties_values"} //= {})->{"final"}
Truth table0%0/2
A
A= $self->{"properties_values"}
| |||||||||||||||||||||||
| 84 | |||||||||||||||||||||||
| 85 | 0 | $pv_current->{store_file} = [map {{raw => $_}} @candidates]; | |||||||||||||||||||||
| 86 | 0 | $pv_final->{store_file} = [map {{raw => $_}} @candidates]; | |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||
| 89 | |||||||||||||||||||||||
| 90 | 1 | 1; | |||||||||||||||||||||
| 91 | |||||||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||||