diff --git a/lib/SLUB/LZA/TA/Command/permanent.pm b/lib/SLUB/LZA/TA/Command/permanent.pm index e655d3e5c9039af6b7d86c6ecff704e1ef489a4a..0300d00de4ae83c13eec4ab9d0bc01c3e709055e 100644 --- a/lib/SLUB/LZA/TA/Command/permanent.pm +++ b/lib/SLUB/LZA/TA/Command/permanent.pm @@ -45,9 +45,23 @@ sub validate_args { return 1; } +sub check_a_bag ($candidate) { + my $bag = Archive::BagIt->new($candidate); + # explicite SHA loading, because + # Archivematica only use SHA512, but have version 0.97 + $bag->use_plugins('Archive::BagIt::Plugin::Algorithm::SHA512'); + my $is_valid; + eval { + $is_valid = $bag->verify_bag({report_all_errors => 1}); + }; + my $line; + $line->{'AIP storage path'} = $candidate; + $line->{'bagit validation result'} = ($is_valid ? "valid" : "invalid"); + return $line; +} + sub execute { my ($self, $opt, $args) = @_; - my @candidates; my $wanted = sub { my ($dev, $ino, $mode, $nlink, $uid, $gid); @@ -63,19 +77,7 @@ sub execute { @{ $SLUB::LZA::TA::config{permanent_volume} } ); my @results = map { - my $candidate = $_; - my $bag = Archive::BagIt->new($candidate); - # explicite SHA loading, because - # Archivematica only use SHA512, but have version 0.97 - $bag->use_plugins('Archive::BagIt::Plugin::Algorithm::SHA512'); - my $is_valid; - eval { - $is_valid = $bag->verify_bag({report_all_errors => 1}); - }; - my $line; - $line->{'AIP storage path'} = $candidate; - $line->{'bagit validation result'} = ($is_valid ? "valid" : "invalid"); - $line; + check_a_bag( $_ ); } (sort @candidates); my @headers = sort keys %{$results[0]}; my $misc_ref;