Skip to content
Snippets Groups Projects
Commit b69ca75b authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- refactoring, rewrite file location and size handling to improve readability and efficiency

parent 47bcd7a7
Branches
No related tags found
No related merge requests found
......@@ -47,7 +47,7 @@ use File::Basename qw(basename dirname);
use File::Find;
use Getopt::Long;
use IO::Handle;
use List::Util qw(first);
use List::Util qw(first zip);
use Path::Tiny;
use Pod::Usage;
use Time::Progress;
......@@ -689,21 +689,11 @@ sub parse_iexml($filename, $recovery_flag) {
my $filegrp = $xp->findnodes("mets:fileGrp[\@ADMID='$repid']", $filesec)->[0];
$ret->{"filepids"} = get_filepids_ref($xp, $filegrp);
$ret->{"files"} = get_files_ref($xp, $filegrp);
my @loc_and_size = map {
my $fpid = $_;
my $location = get_file_path($xp, $filegrp, $fpid);
#my $location = get_file_path_rx($slurp, $fpid);
#say "location=$location";
my $size = get_filesize($xp, $fpid);
#my $size = get_filesize_rx($slurp, $fpid);
#say "size=$size";
[ $location, $size ];
} @{$ret->{"filepids"}};
foreach my $entry (@loc_and_size) {
my ($location, $size) = @{$entry};
$ret->{"sizes"}->{$location} = $size;
}
my @locations = map {get_file_path($xp, $filegrp, $_)} @{$ret->{"filepids"}};
my @sizes = map {get_filesize($xp, $_)} @{$ret->{"filepids"}};
my %ls = map { $_->[0] => $_->[1] } zip \@locations, \@sizes;
$ret->{"sizes"} = \%ls;
#use Data::Printer; p($ret);
return $ret;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment